Compare commits

...

16 Commits

Author SHA1 Message Date
Sergey Rostov
8e817c3ba0 ScriptTemplatesClassRootsIndex: inc version and minor fixes
Content was changed, so we should force reindex.

Minor changes:
- There is no need to save a string, we can just save nothing
 by using the Unit value (see UnitKey.save and UnitKey.read)
- Unit can be shared between all indexes, so we can extract UnitKey object
- It would be good to extract abstract class FileListIndex:
  - for better readability: separate the logic of the specific index from the common FileListIndex implementation
  - someone can use it also
- mapOf (Unit to null) will create singletonMap itself and more readable
- ScriptTemplatesClassRootsIndex.KEY perhaps better to call NAME
2020-07-08 11:02:01 +03:00
Mikhail Glukhikh
4a988f467a [FIR2IR] Code cleanup: DelegatedMemberGenerator 2020-07-08 10:05:07 +03:00
Juan Chen
d163853c97 [FIR] add support for implementation by delgation
This commit handles "subclass: super-interface by delegate-expression".

During Psi2Fir, for each delegate, we add to the subclass a synthetic
field (which has type super-interface), and an assignment of the
delegate-expression to the synthetic field in the primary constructor,
so that the delegate-expression can be resolved and transformed along
the way.

During Fir2Ir, we look up delegatable members from the super-interface
and generate corresponding functions/properties for the subclass.

TODO: support for generic delegatable members and generic
super-interface.
2020-07-08 09:42:24 +03:00
Natalia Selezneva
1d45dc8d81 Optimize ScriptTemplatesFromDependenciesProvider
No needs to convert file.url to VirtualFile
because index already has getContainingFiles method
Do not iterate through all children of VirtualFile
to avoid VFS events initialisation for those files
there is no guarantee that file is under source root
so is can be not present is vfs at this moment
2020-07-07 23:26:58 +03:00
Vladimir Dolzhenko
45600830d3 Fixed locking granularity in ScriptDefinitionsManager
#KT-34552 Fixed
#KT-39547 Fixed
2020-07-07 19:15:32 +00:00
simon.ogorodnik
77ccb3767c [FIR] Add system property selector for lightTree2fir / psi2fir 2020-07-07 21:47:24 +03:00
simon.ogorodnik
a460b8f2f4 [FIR] Support source directories for lightTree2fir 2020-07-07 21:47:24 +03:00
simon.ogorodnik
6c7a40627f [FIR] Forbid constructors in processFunctionsByName 2020-07-07 21:47:24 +03:00
simon.ogorodnik
6bc654ee49 [FIR] Add full compiler pipeline modularized test
Fixup: allow kotlin package
2020-07-07 21:47:24 +03:00
simon.ogorodnik
b48dfe9b3d Allow dirs as content root in modularized tests 2020-07-07 21:47:24 +03:00
simon.ogorodnik
bf1c3777ab Add IR specific timing measurements to performance manager 2020-07-07 21:47:24 +03:00
simon.ogorodnik
0de70d295a Fix argument names 2020-07-07 21:47:23 +03:00
simon.ogorodnik
b401443dbd Compute GC metrics only during compilation 2020-07-07 21:47:23 +03:00
simon.ogorodnik
6095ec66ed Allow to pass external performance manager to compiler 2020-07-07 21:47:23 +03:00
Alexander Udalov
8c71d8f126 Undeprecate VariableDescriptorWithAccessors.isDelegated
Apparently there's quite a few valid usages of this method outside of
the compiler frontend, where manual suppression is annoying.
2020-07-07 18:09:40 +02:00
Jinseong Jeon
50b2ea7053 FIR: avoid cast exception in Candidate.prepareExpectedType 2020-07-07 16:55:53 +03:00
113 changed files with 1615 additions and 404 deletions

View File

@@ -210,7 +210,6 @@ public class PropertyCodegen {
if (kind == OwnerKind.DEFAULT_IMPLS && isDefaultAccessor) return false;
// Delegated or extension properties can only be referenced via accessors
//noinspection deprecation
if (descriptor.isDelegated() || descriptor.getExtensionReceiverParameter() != null) return true;
// Companion object properties should have accessors for non-private properties because these properties can be referenced
@@ -337,11 +336,8 @@ public class PropertyCodegen {
return;
}
@SuppressWarnings("deprecation")
boolean isDelegate = descriptor.isDelegated();
Object defaultValue;
if (isDelegate) {
if (descriptor.isDelegated()) {
defaultValue = null;
}
else if (Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor))) {
@@ -357,7 +353,7 @@ public class PropertyCodegen {
return;
}
generateBackingField(descriptor, isDelegate, defaultValue, isBackingFieldOwner);
generateBackingField(descriptor, descriptor.isDelegated(), defaultValue, isBackingFieldOwner);
}
// Annotations on properties are stored in bytecode on an empty synthetic method. This way they're still
@@ -522,9 +518,7 @@ public class PropertyCodegen {
FunctionGenerationStrategy strategy;
if (accessor == null || !accessor.hasBody()) {
@SuppressWarnings("deprecation")
boolean isDelegated = descriptor.getCorrespondingProperty().isDelegated();
if (isDelegated) {
if (descriptor.getCorrespondingProperty().isDelegated()) {
strategy = new DelegatedPropertyAccessorStrategy(state, descriptor);
}
else {

View File

@@ -128,7 +128,7 @@ fun createFreeFakeLocalPropertyDescriptor(descriptor: LocalVariableDescriptor, t
val property = PropertyDescriptorImpl.create(
descriptor.containingDeclaration, descriptor.annotations, Modality.FINAL, descriptor.visibility, descriptor.isVar,
descriptor.name, CallableMemberDescriptor.Kind.DECLARATION, descriptor.source, false, descriptor.isConst,
false, false, false, @Suppress("DEPRECATION") descriptor.isDelegated
false, false, false, descriptor.isDelegated
)
property.setType(
descriptor.type, descriptor.typeParameters,

View File

@@ -74,7 +74,6 @@ fun ExpressionCodegen.createRangeValueForExpression(rangeExpression: KtExpressio
}
}
@Suppress("DEPRECATION")
fun isLocalVarReference(rangeExpression: KtExpression, bindingContext: BindingContext): Boolean {
if (rangeExpression !is KtSimpleNameExpression) return false
val resultingDescriptor = rangeExpression.getResolvedCall(bindingContext)?.resultingDescriptor ?: return false

View File

@@ -23,7 +23,9 @@ import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter
import org.jetbrains.kotlin.codegen.signature.JvmSignatureWriter
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.*
import org.jetbrains.kotlin.descriptors.impl.LocalVariableAccessorDescriptor
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature
import org.jetbrains.kotlin.load.java.JvmAbi
@@ -1208,7 +1210,7 @@ class KotlinTypeMapper @JvmOverloads constructor(
return StackValue.sharedTypeForType(mapType(receiverParameter.type))
}
if (descriptor is LocalVariableDescriptor && @Suppress("DEPRECATION") descriptor.isDelegated) {
if (descriptor is LocalVariableDescriptor && descriptor.isDelegated) {
return null
}

View File

@@ -45,7 +45,7 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
protected abstract val performanceManager: CommonCompilerPerformanceManager
protected open fun createPerformanceManager(arguments: A): CommonCompilerPerformanceManager = performanceManager
protected open fun createPerformanceManager(arguments: A, services: Services): CommonCompilerPerformanceManager = performanceManager
// Used in CompilerRunnerUtil#invokeExecMethod, in Eclipse plugin (KotlinCLICompiler) and in kotlin-gradle-plugin (GradleCompilerRunner)
fun execAndOutputXml(errStream: PrintStream, services: Services, vararg args: String): ExitCode {
@@ -58,7 +58,7 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
}
public override fun execImpl(messageCollector: MessageCollector, services: Services, arguments: A): ExitCode {
val performanceManager = createPerformanceManager(arguments)
val performanceManager = createPerformanceManager(arguments, services)
if (arguments.reportPerf || arguments.dumpPerf != null) {
performanceManager.enableCollectingPerformanceStatistics()
}

View File

@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.cli.common
import org.jetbrains.kotlin.util.PerformanceCounter
import java.io.File
import java.lang.management.GarbageCollectorMXBean
import java.lang.management.ManagementFactory
import java.util.concurrent.TimeUnit
@@ -18,13 +19,21 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
private var analysisStart: Long = 0
private var generationStart: Long = 0
private var startGCData = mutableMapOf<String, GCData>()
private var irTranslationStart: Long = 0
private var irGenerationStart: Long = 0
fun getMeasurementResults(): List<PerformanceMeasurement> = measurements
fun enableCollectingPerformanceStatistics() {
isEnabled = true
PerformanceCounter.setTimeCounterEnabled(true)
ManagementFactory.getGarbageCollectorMXBeans().associateTo(startGCData) { it.name to GCData(it) }
}
private fun deltaTime(start: Long): Long = PerformanceCounter.currentTime() - start
open fun notifyCompilerInitialized() {
if (!isEnabled) return
recordInitializationTime()
@@ -50,9 +59,39 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
generationStart = PerformanceCounter.currentTime()
}
open fun notifyGenerationFinished(lines: Int, files: Int, additionalDescription: String) {
open fun notifyGenerationFinished(files: Int, lines: Int, additionalDescription: String) {
val time = PerformanceCounter.currentTime() - generationStart
measurements += CodeGenerationMeasurement(lines, files, TimeUnit.NANOSECONDS.toMillis(time), additionalDescription)
measurements += CodeGenerationMeasurement(files, lines, TimeUnit.NANOSECONDS.toMillis(time), additionalDescription)
}
open fun notifyIRTranslationStarted() {
irTranslationStart = PerformanceCounter.currentTime()
}
open fun notifyIRTranslationFinished(files: Int, lines: Int, additionalDescription: String?) {
val time = deltaTime(irTranslationStart)
measurements += IRMeasurement(
files,
lines,
TimeUnit.NANOSECONDS.toMillis(time),
additionalDescription,
IRMeasurement.Kind.Translation
)
}
open fun notifyIRGenerationStarted() {
irGenerationStart = PerformanceCounter.currentTime()
}
open fun notifyIRGenerationFinished(files: Int, lines: Int, additionalDescription: String) {
val time = deltaTime(irGenerationStart)
measurements += IRMeasurement(
files,
lines,
TimeUnit.NANOSECONDS.toMillis(time),
additionalDescription,
IRMeasurement.Kind.Generation
)
}
fun dumpPerformanceReport(destination: File) {
@@ -63,7 +102,14 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
if (!isEnabled) return
ManagementFactory.getGarbageCollectorMXBeans().forEach {
measurements += GarbageCollectionMeasurement(it.name, it.collectionTime)
val startCounts = startGCData[it.name]
val startCollectionTime = startCounts?.collectionTime ?: 0
val startCollectionCount = startCounts?.collectionCount ?: 0
measurements += GarbageCollectionMeasurement(
it.name,
it.collectionTime - startCollectionTime,
it.collectionCount - startCollectionCount
)
}
}
@@ -89,4 +135,8 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
}.toByteArray()
open fun notifyRepeat(total: Int, number: Int) {}
private data class GCData(val name: String, val collectionTime: Long, val collectionCount: Long) {
constructor(bean: GarbageCollectorMXBean) : this(bean.name, bean.collectionTime, bean.collectionCount)
}
}

View File

@@ -20,13 +20,13 @@ class CompilerInitializationMeasurement(private val milliseconds: Long) : Perfor
}
class CodeAnalysisMeasurement(private val files: Int, val lines: Int, private val milliseconds: Long, private val description: String?) :
class CodeAnalysisMeasurement(val files: Int, val lines: Int, val milliseconds: Long, private val description: String?) :
PerformanceMeasurement {
private val speed: Double = lines.toDouble() * 1000 / milliseconds
val lps: Double = lines.toDouble() * 1000 / milliseconds
override fun render(): String =
"ANALYZE: $files files ($lines lines) ${description ?: ""}in $milliseconds ms - ${"%.3f".format(speed)} loc/s"
"ANALYZE: $files files ($lines lines) ${description ?: ""}in $milliseconds ms - ${"%.3f".format(lps)} loc/s"
}
@@ -40,11 +40,23 @@ class CodeGenerationMeasurement(private val files: Int, val lines: Int, private
}
class GarbageCollectionMeasurement(private val garbageCollectionKind: String, private val milliseconds: Long) : PerformanceMeasurement {
override fun render(): String = "GC time for $garbageCollectionKind is $milliseconds ms"
class GarbageCollectionMeasurement(val garbageCollectionKind: String, val milliseconds: Long, val count: Long) : PerformanceMeasurement {
override fun render(): String = "GC time for $garbageCollectionKind is $milliseconds ms, $count collections"
}
class PerformanceCounterMeasurement(private val counterReport: String) : PerformanceMeasurement {
override fun render(): String = counterReport
}
class IRMeasurement(val files: Int, val lines: Int, val milliseconds: Long, private val description: String?, val kind: Kind) :
PerformanceMeasurement {
val lps: Double = lines.toDouble() * 1000 / milliseconds
override fun render(): String =
"IR: $kind $files files ($lines lines) ${description ?: ""}in $milliseconds ms - ${"%.3f".format(lps)} loc/s"
enum class Kind {
Generation, Translation
}
}

View File

@@ -267,7 +267,9 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
override val performanceManager: CommonCompilerPerformanceManager
get() = error("Unsupported")
override fun createPerformanceManager(arguments: K2JVMCompilerArguments): CommonCompilerPerformanceManager {
override fun createPerformanceManager(arguments: K2JVMCompilerArguments, services: Services): CommonCompilerPerformanceManager {
val externalManager = services[CommonCompilerPerformanceManager::class.java]
if (externalManager != null) return externalManager
val argument = arguments.profileCompilerCommand ?: return K2JVMCompilerPerformanceManager()
return ProfilingCompilerPerformanceManager.create(argument)
}

View File

@@ -374,6 +374,7 @@ object KotlinToJVMBytecodeCompiler {
performanceManager?.notifyGenerationStarted()
val signaturer = IdSignatureDescriptor(JvmManglerDesc())
performanceManager?.notifyIRTranslationStarted()
val (moduleFragment, symbolTable, sourceManager, components) =
Fir2IrConverter.createModuleFragment(
session, resolveTransformer.scopeSession, firFiles,
@@ -381,6 +382,9 @@ object KotlinToJVMBytecodeCompiler {
generatorExtensions = JvmGeneratorExtensions(),
mangler = FirJvmKotlinMangler(session)
)
performanceManager?.notifyIRTranslationFinished(ktFiles.size, codeLines, debugTargetDescription)
val dummyBindingContext = NoScopeRecordCliBindingTrace().bindingContext
val codegenFactory = JvmIrCodegenFactory(moduleConfiguration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases))
@@ -402,7 +406,7 @@ object KotlinToJVMBytecodeCompiler {
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
performanceManager?.notifyIRGenerationStarted()
generationState.beforeCompile()
codegenFactory.generateModuleInFrontendIRMode(
generationState, moduleFragment, symbolTable, sourceManager
@@ -431,6 +435,7 @@ object KotlinToJVMBytecodeCompiler {
generationState.extraJvmDiagnosticsTrace.bindingContext, environment.messageCollector
)
performanceManager?.notifyIRGenerationFinished(ktFiles.size, codeLines, additionalDescription = debugTargetDescription)
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
outputs[module] = generationState
}

View File

@@ -13,8 +13,11 @@ FILE: delegatedSuperType.kt
}
public final class C : R|A| {
local final field $$delegate_0: R|A|
public constructor(b: R|B|): R|C| {
super<R|kotlin/Any|>()
this@R|/C|.R|<local>/$$delegate_0| = R|<local>/b|
}
public final val b: R|B| = R|<local>/b|

View File

@@ -407,6 +407,10 @@ fun isOverriding(
// Not checking the field type (they should match each other if everything other match, otherwise it's a compilation error)
target.name == superCandidate.name
}
target is IrProperty && superCandidate is IrProperty -> {
// Not checking the property type (they should match each other if names match, otherwise it's a compilation error)
target.name == superCandidate.name
}
else -> false
}
}

View File

@@ -5,7 +5,10 @@
package org.jetbrains.kotlin.fir.backend
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.lazy.Fir2IrLazyClass
import org.jetbrains.kotlin.fir.resolve.firProvider
@@ -23,7 +26,10 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrEnumEntryImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrTypeAliasImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrTypeParameterImpl
import org.jetbrains.kotlin.ir.descriptors.*
import org.jetbrains.kotlin.ir.descriptors.WrappedClassDescriptor
import org.jetbrains.kotlin.ir.descriptors.WrappedEnumEntryDescriptor
import org.jetbrains.kotlin.ir.descriptors.WrappedTypeAliasDescriptor
import org.jetbrains.kotlin.ir.descriptors.WrappedTypeParameterDescriptor
import org.jetbrains.kotlin.ir.expressions.impl.IrEnumConstructorCallImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol

View File

@@ -87,7 +87,7 @@ class Fir2IrConverter(
anonymousObject.getPrimaryConstructorIfAny()?.let {
irClass.declarations += declarationStorage.createIrConstructor(it, irClass)
}
for (declaration in anonymousObject.declarations) {
for (declaration in sortBySynthetic(anonymousObject.declarations)) {
if (declaration is FirRegularClass) {
registerClassAndNestedClasses(declaration, irClass)
processClassAndNestedClassHeaders(declaration)
@@ -98,6 +98,13 @@ class Fir2IrConverter(
return irClass
}
// Sort declarations so that all non-synthetic declarations are before synthetic ones.
// This is needed because converting synthetic fields for implementation delegation needs to know
// existing declarations in the class to avoid adding redundant delegated members.
private fun sortBySynthetic(declarations: List<FirDeclaration>) : Iterable<FirDeclaration> {
return declarations.sortedBy { it.isSynthetic }
}
private fun processClassMembers(
regularClass: FirRegularClass,
irClass: IrClass = classifierStorage.getCachedIrClass(regularClass)!!
@@ -105,7 +112,7 @@ class Fir2IrConverter(
regularClass.getPrimaryConstructorIfAny()?.let {
irClass.declarations += declarationStorage.createIrConstructor(it, irClass)
}
for (declaration in regularClass.declarations) {
for (declaration in sortBySynthetic(regularClass.declarations)) {
val irDeclaration = processMemberDeclaration(declaration, irClass) ?: continue
irClass.declarations += irDeclaration
}
@@ -142,6 +149,13 @@ class Fir2IrConverter(
is FirProperty -> {
declarationStorage.createIrProperty(declaration, parent)
}
is FirField -> {
if (declaration.isSynthetic) {
declarationStorage.createIrFieldAndDelegatedMembers(declaration, parent as IrClass)
} else {
throw AssertionError("Unexpected non-synthetic field: ${declaration::class}")
}
}
is FirConstructor -> if (!declaration.isPrimary) {
declarationStorage.createIrConstructor(declaration, parent as IrClass)
} else {

View File

@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.fir.FirAnnotationContainer
import org.jetbrains.kotlin.fir.backend.generators.AnnotationGenerator
import org.jetbrains.kotlin.fir.backend.generators.DelegatedMemberGenerator
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter
@@ -36,12 +37,9 @@ import org.jetbrains.kotlin.ir.declarations.impl.*
import org.jetbrains.kotlin.ir.descriptors.*
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.types.IrErrorType
import org.jetbrains.kotlin.ir.types.IrSimpleType
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
@@ -78,6 +76,8 @@ class Fir2IrDeclarationStorage(
private val localStorage = Fir2IrLocalStorage()
private val delegatedMemberGenerator = DelegatedMemberGenerator(components)
private fun areCompatible(firFunction: FirFunction<*>, irFunction: IrFunction): Boolean {
if (firFunction is FirSimpleFunction && irFunction is IrSimpleFunction) {
if (irFunction.name != firFunction.name) return false
@@ -700,9 +700,39 @@ class Fir2IrDeclarationStorage(
fun getCachedIrProperty(property: FirProperty): IrProperty? = propertyCache[property]
private fun createIrField(field: FirField): IrField {
fun getCachedIrField(field: FirField): IrField? = fieldCache[field]
fun createIrFieldAndDelegatedMembers(field: FirField, parent: IrClass): IrField {
val irField = createIrField(field, origin = IrDeclarationOrigin.DELEGATE)
irField.setAndModifyParent(parent)
delegatedMemberGenerator.generate(irField, parent)
return irField
}
internal fun findOverriddenFirFunction(irFunction: IrSimpleFunction, superClassId: ClassId): FirFunction<*>? {
val functions = getFirClassByFqName(superClassId)?.declarations?.filter {
it is FirFunction<*> && functionCache.containsKey(it) && irFunction.overrides(functionCache[it]!!)
}
return if (functions.isNullOrEmpty()) null else functions.first() as FirFunction<*>
}
internal fun findOverriddenFirProperty(irProperty: IrProperty, superClassId: ClassId): FirProperty? {
val properties = getFirClassByFqName(superClassId)?.declarations?.filter {
it is FirProperty && it.name == irProperty.name
}
return if (properties.isNullOrEmpty()) null else properties.first() as FirProperty
}
private fun getFirClassByFqName(classId: ClassId): FirClass<*>? {
val declaration = firProvider.getClassLikeSymbolByFqName(classId) ?: firSymbolProvider.getClassLikeSymbolByFqName(classId)
return declaration?.fir as? FirClass<*>
}
private fun createIrField(
field: FirField,
origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB
): IrField {
val descriptor = WrappedFieldDescriptor()
val origin = IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB
val type = field.returnTypeRef.toIrType()
return field.convertWithOffsets { startOffset, endOffset ->
symbolTable.declareField(

View File

@@ -76,6 +76,14 @@ class Fir2IrVisitor(
TODO("Should not be here: ${element.render()}")
}
override fun visitField(field: FirField, data: Any?): IrField {
if (field.isSynthetic) {
return declarationStorage.getCachedIrField(field)!!
} else {
throw AssertionError("Unexpected field: ${field.render()}")
}
}
override fun visitFile(file: FirFile, data: Any?): IrFile {
return conversionScope.withParent(declarationStorage.getIrFile(file)) {
file.declarations.forEach {

View File

@@ -59,6 +59,16 @@ internal class ClassMemberGenerator(
else -> null
}
}
// Add delegated members *before* fake override generations.
// Otherwise, fake overrides for delegated members, which are redundant, will be added.
irClass.declarations.filter {
it.origin == IrDeclarationOrigin.DELEGATED_MEMBER
}.forEach {
when (it) {
is IrSimpleFunction -> processedCallableNames += it.name
is IrProperty -> processedCallableNames += it.name
}
}
// Add synthetic members *before* fake override generations.
// Otherwise, redundant members, e.g., synthetic toString _and_ fake override toString, will be added.
if (irClass.isInline && klass.getPrimaryConstructorIfAny() != null) {

View File

@@ -0,0 +1,271 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.backend.generators
import org.jetbrains.kotlin.backend.common.ir.isFinalClass
import org.jetbrains.kotlin.backend.common.ir.isOverridable
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.fir.backend.Fir2IrComponents
import org.jetbrains.kotlin.fir.backend.FirMetadataSource
import org.jetbrains.kotlin.fir.backend.declareThisReceiverParameter
import org.jetbrains.kotlin.fir.backend.isOverriding
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.builder.buildProperty
import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunction
import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameterCopy
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrPropertyImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
import org.jetbrains.kotlin.ir.descriptors.WrappedPropertyDescriptor
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.types.classOrNull
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
import org.jetbrains.kotlin.ir.types.isNothing
import org.jetbrains.kotlin.ir.types.isUnit
import org.jetbrains.kotlin.ir.util.classId
import org.jetbrains.kotlin.ir.util.defaultType
import org.jetbrains.kotlin.ir.util.hasAnnotation
import org.jetbrains.kotlin.ir.util.isFakeOverride
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
/**
* A generator for delegated members from implementation by delegation.
*
* It assumes a synthetic field with the super-interface type has been created for the delegate expression. It looks for delegatable
* methods and properties in the super-interface, and creates corresponding members in the subclass.
* TODO: generic super interface types and generic delegated members.
*/
internal class DelegatedMemberGenerator(
private val components: Fir2IrComponents
) : Fir2IrComponents by components {
// Generate delegated members for [subClass]. The synthetic field [irField] has the super interface type.
fun generate(irField: IrField, subClass: IrClass) {
val superClass = (irField.type as IrSimpleTypeImpl).classOrNull?.owner ?: return
val superClassId = superClass.classId ?: return
superClass.declarations.filter {
it.isDelegatable() && !subClass.declarations.any { decl -> isOverriding(irBuiltIns, decl, it) }
}.forEach {
if (it is IrSimpleFunction) {
val firFunction = declarationStorage.findOverriddenFirFunction(it, superClassId) ?: return
val function = generateDelegatedFunction(subClass, irField, it, firFunction)
subClass.addMember(function)
} else if (it is IrProperty) {
val firProperty = declarationStorage.findOverriddenFirProperty(it, superClassId) ?: return
generateDelegatedProperty(subClass, irField, it, firProperty)
}
}
}
private fun IrDeclaration.isDelegatable(): Boolean {
return isOverridable()
&& !isFakeOverride
&& !(this is IrSimpleFunction && hasDefaultImplementation())
}
private fun IrDeclaration.isOverridable(): Boolean {
return when (this) {
is IrSimpleFunction -> this.isOverridable
is IrProperty -> visibility != Visibilities.PRIVATE && modality != Modality.FINAL && (parent as? IrClass)?.isFinalClass != true
else -> false
}
}
private fun IrSimpleFunction.hasDefaultImplementation(): Boolean {
var realFunction: IrSimpleFunction? = this
while (realFunction != null && realFunction.isFakeOverride) {
realFunction = realFunction.overriddenSymbols.firstOrNull()?.owner
}
return realFunction != null
&& (realFunction.modality != Modality.ABSTRACT && realFunction.origin == IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB
|| realFunction.annotations.hasAnnotation(FqName("kotlin.jvm.JvmDefault")))
}
private fun generateDelegatedFunction(
subClass: IrClass,
irField: IrField,
superFunction: IrSimpleFunction,
firSuperFunction: FirFunction<*>
): IrSimpleFunction {
val startOffset = irField.startOffset
val endOffset = irField.endOffset
val descriptor = WrappedSimpleFunctionDescriptor()
val origin = IrDeclarationOrigin.DELEGATED_MEMBER
val modality = if (superFunction.modality == Modality.ABSTRACT) Modality.OPEN else superFunction.modality
val delegateFunction = symbolTable.declareSimpleFunction(descriptor) { symbol ->
IrFunctionImpl(
startOffset,
endOffset,
origin,
symbol,
superFunction.name,
superFunction.visibility,
modality,
superFunction.returnType,
superFunction.isInline,
superFunction.isExternal,
superFunction.isTailrec,
superFunction.isSuspend,
superFunction.isOperator,
superFunction.isExpect
).apply {
descriptor.bind(this)
declarationStorage.enterScope(this)
this.parent = subClass
overriddenSymbols = listOf(superFunction.symbol)
dispatchReceiverParameter = declareThisReceiverParameter(symbolTable, subClass.defaultType, origin)
// TODO: type parameters from superFunctions and type substitution when super interface types are generic
superFunction.valueParameters.forEach { valueParameter ->
val parameterDescriptor = WrappedValueParameterDescriptor()
valueParameters += symbolTable.declareValueParameter(
startOffset, endOffset, origin, parameterDescriptor, valueParameter.type
) { symbol ->
IrValueParameterImpl(
startOffset, endOffset, origin, symbol,
valueParameter.name, valueParameter.index, valueParameter.type,
null, valueParameter.isCrossinline, valueParameter.isNoinline
).also {
parameterDescriptor.bind(it)
it.parent = this
}
}
}
val visibility = when (firSuperFunction) {
is FirSimpleFunction -> firSuperFunction.status.visibility
is FirPropertyAccessor -> firSuperFunction.status.visibility
else -> Visibilities.PUBLIC
}
metadata = FirMetadataSource.Function(
buildSimpleFunction {
this.origin = FirDeclarationOrigin.Synthetic
this.name = superFunction.name
this.symbol = FirNamedFunctionSymbol(getCallableId(subClass, superFunction.name))
this.status = FirDeclarationStatusImpl(visibility, modality)
this.session = components.session
this.returnTypeRef = firSuperFunction.returnTypeRef
firSuperFunction.valueParameters.map { superParameter ->
this.valueParameters.add(
buildValueParameterCopy(superParameter) {
this.origin = FirDeclarationOrigin.Synthetic
this.session = components.session
this.symbol = FirVariableSymbol(superParameter.name)
}
)
}
}
)
declarationStorage.leaveScope(this)
}
}
val body = IrBlockBodyImpl(startOffset, endOffset)
val irCall = IrCallImpl(
startOffset,
endOffset,
superFunction.returnType,
superFunction.symbol,
superFunction.typeParameters.size,
superFunction.valueParameters.size
).apply {
dispatchReceiver =
IrGetFieldImpl(
startOffset, endOffset,
irField.symbol,
irField.type,
IrGetValueImpl(
startOffset, endOffset,
delegateFunction.dispatchReceiverParameter?.type!!,
delegateFunction.dispatchReceiverParameter?.symbol!!
)
)
extensionReceiver =
delegateFunction.extensionReceiverParameter?.let { extensionReceiver ->
IrGetValueImpl(startOffset, endOffset, extensionReceiver.type, extensionReceiver.symbol)
}
delegateFunction.valueParameters.forEach {
putValueArgument(it.index, IrGetValueImpl(startOffset, endOffset, it.type, it.symbol))
}
}
if (superFunction.returnType.isUnit() || superFunction.returnType.isNothing()) {
body.statements.add(irCall)
} else {
val irReturn = IrReturnImpl(startOffset, endOffset, irBuiltIns.nothingType, delegateFunction.symbol, irCall)
body.statements.add(irReturn)
}
delegateFunction.body = body
return delegateFunction
}
private fun generateDelegatedProperty(
subClass: IrClass,
irField: IrField,
superProperty: IrProperty,
firSuperProperty: FirProperty
) {
val startOffset = irField.startOffset
val endOffset = irField.endOffset
val descriptor = WrappedPropertyDescriptor()
val modality = if (superProperty.modality == Modality.ABSTRACT) Modality.OPEN else superProperty.modality
symbolTable.declareProperty(
startOffset, endOffset,
IrDeclarationOrigin.DELEGATED_MEMBER, descriptor, superProperty.isDelegated
) { symbol ->
IrPropertyImpl(
startOffset, endOffset, IrDeclarationOrigin.DELEGATED_MEMBER, symbol,
superProperty.name, superProperty.visibility,
modality,
isVar = superProperty.isVar,
isConst = superProperty.isConst,
isLateinit = superProperty.isLateinit,
isDelegated = superProperty.isDelegated,
isExternal = false,
isExpect = superProperty.isExpect,
isFakeOverride = false
).apply {
descriptor.bind(this)
this.parent = subClass
getter = generateDelegatedFunction(subClass, irField, superProperty.getter!!, firSuperProperty.getter!!).apply {
this.correspondingPropertySymbol = symbol
}
if (superProperty.isVar) {
setter = generateDelegatedFunction(subClass, irField, superProperty.setter!!, firSuperProperty.setter!!).apply {
this.correspondingPropertySymbol = symbol
}
}
this.metadata = FirMetadataSource.Property(
buildProperty {
this.name = superProperty.name
this.origin = FirDeclarationOrigin.Synthetic
this.session = components.session
this.status = FirDeclarationStatusImpl(firSuperProperty.status.visibility, modality)
this.isLocal = firSuperProperty.isLocal
this.returnTypeRef = firSuperProperty.returnTypeRef
this.symbol = FirPropertySymbol(getCallableId(subClass, superProperty.name))
this.isVar = firSuperProperty.isVar
}
)
subClass.addMember(this)
}
}
}
private fun getCallableId(irClass: IrClass, name: Name): CallableId {
val classId = irClass.classId
return if (classId != null) CallableId(classId, name) else CallableId(name)
}
}

View File

@@ -88,7 +88,7 @@ abstract class AbstractModularizedTest : KtUsefulTestCase() {
configuration.addAll(
CLIConfigurationKeys.CONTENT_ROOTS,
moduleData.sources.filter { it.extension == "kt" }.map { KotlinSourceRoot(it.absolutePath, false) })
moduleData.sources.filter { it.extension == "kt" || it.isDirectory }.map { KotlinSourceRoot(it.absolutePath, false) })
return configuration
}

View File

@@ -41,6 +41,7 @@ internal val PASSES = System.getProperty("fir.bench.passes")?.toInt() ?: 3
internal val SEPARATE_PASS_DUMP = System.getProperty("fir.bench.dump.separate_pass", "false").toBooleanLenient()!!
private val APPEND_ERROR_REPORTS = System.getProperty("fir.bench.report.errors.append", "false").toBooleanLenient()!!
private val RUN_CHECKERS = System.getProperty("fir.bench.run.checkers", "false").toBooleanLenient()!!
private val USE_LIGHT_TREE = System.getProperty("fir.bench.use.light.tree", "false").toBooleanLenient()!!
class FirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
@@ -49,7 +50,7 @@ class FirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
private var bestStatistics: FirResolveBench.TotalStatistics? = null
private var bestPass: Int = 0
private fun runAnalysis(moduleData: ModuleData, environment: KotlinCoreEnvironment, useLightTree: Boolean = false) {
private fun runAnalysis(moduleData: ModuleData, environment: KotlinCoreEnvironment) {
val project = environment.project
val ktFiles = environment.getSourceFiles()
@@ -68,9 +69,19 @@ class FirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
}
val firProvider = session.firProvider as FirProviderImpl
val firFiles = if (useLightTree) {
val firFiles = if (USE_LIGHT_TREE) {
val lightTree2Fir = LightTree2Fir(session, firProvider.kotlinScopeProvider, stubMode = false)
bench.buildFiles(lightTree2Fir, moduleData.sources.filter { it.extension == "kt" })
val allSourceFiles = moduleData.sources.flatMap {
if (it.isDirectory) {
it.walkTopDown().toList()
} else {
listOf(it)
}
}.filter {
it.extension == "kt"
}
bench.buildFiles(lightTree2Fir, allSourceFiles)
} else {
val builder = RawFirBuilder(session, firProvider.kotlinScopeProvider, stubMode = false)
bench.buildFiles(builder, ktFiles)

View File

@@ -0,0 +1,188 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir
import com.intellij.util.io.delete
import org.jetbrains.kotlin.cli.common.*
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.config.Services
import org.jetbrains.kotlin.fir.TableTimeUnit.MS
import org.jetbrains.kotlin.fir.TableTimeUnit.S
import org.jetbrains.kotlin.fir.scopes.ProcessorAction
import org.jetbrains.kotlin.util.PerformanceCounter
import java.io.FileOutputStream
import java.io.PrintStream
import java.nio.file.Files
class FullPipelineModularizedTest : AbstractModularizedTest() {
override fun beforePass() {
totalPassResult = CumulativeTime()
totalModules = 0
okModules = 0
}
private data class CumulativeTime(
val gcInfo: Map<String, GCInfo>,
val analysis: Long,
val translation: Long,
val generation: Long,
val files: Int,
val lines: Int
) {
constructor() : this(emptyMap(), 0, 0, 0, 0, 0)
operator fun plus(other: CumulativeTime): CumulativeTime {
return CumulativeTime(
(gcInfo.values + other.gcInfo.values).groupingBy { it.name }.reduce { key, accumulator, element ->
GCInfo(key, accumulator.gcTime + element.gcTime, accumulator.collections + element.collections)
},
analysis + other.analysis,
translation + other.translation,
generation + other.generation,
files + other.files,
lines + other.lines
)
}
fun totalTime() = analysis + translation + generation
}
private lateinit var totalPassResult: CumulativeTime
private var totalModules = 0
private var okModules = 0
override fun afterPass(pass: Int) {
createReport()
}
private fun createReport() {
formatReport(System.out)
PrintStream(
FileOutputStream(
reportDir().resolve("report-$reportDateStr.log"),
true
)
).use { stream ->
formatReport(stream)
stream.println()
stream.println()
}
}
private fun formatReport(stream: PrintStream) {
stream.println("TOTAL MODULES: $totalModules")
stream.println("OK MODULES: $okModules")
val total = totalPassResult
var totalGcTimeMs = 0L
var totalGcCount = 0L
printTable(stream) {
row("Name", "Time", "Count")
separator()
fun gcRow(name: String, timeMs: Long, count: Long) {
row {
cell(name, align = LEFT)
timeCell(timeMs, inputUnit = MS)
cell(count.toString())
}
}
for (measurement in total.gcInfo.values) {
totalGcTimeMs += measurement.gcTime
totalGcCount += measurement.collections
gcRow(measurement.name, measurement.gcTime, measurement.collections)
}
separator()
gcRow("Total", totalGcTimeMs, totalGcCount)
}
printTable(stream) {
row("Phase", "Time", "Files", "L/S")
separator()
fun phase(name: String, timeMs: Long, files: Int, lines: Int) {
row {
cell(name, align = LEFT)
timeCell(timeMs, inputUnit = MS)
cell(files.toString())
linePerSecondCell(lines, timeMs, timeUnit = MS)
}
}
phase("Analysis", total.analysis, total.files, total.lines)
phase("Translation", total.translation, total.files, total.lines)
phase("Generation", total.generation, total.files, total.lines)
separator()
phase("Total", total.totalTime(), total.files, total.lines)
}
}
override fun processModule(moduleData: ModuleData): ProcessorAction {
val compiler = K2JVMCompiler()
val args = compiler.createArguments()
args.reportPerf = true
args.jvmTarget = "1.8"
args.useFir = true
args.classpath = moduleData.classpath.joinToString(separator = ":") { it.absolutePath }
args.javaSourceRoots = moduleData.javaSourceRoots.map { it.absolutePath }.toTypedArray()
args.allowKotlinPackage = true
args.freeArgs = moduleData.sources.map { it.absolutePath }
val tmp = Files.createTempDirectory("compile-output")
args.destination = tmp.toAbsolutePath().toFile().toString()
val manager = CompilerPerformanceManager()
val services = Services.Builder().register(CommonCompilerPerformanceManager::class.java, manager).build()
val result = try {
compiler.exec(PrintingMessageCollector(System.out, MessageRenderer.GRADLE_STYLE, false), services, args)
} catch (e: Exception) {
e.printStackTrace()
ExitCode.INTERNAL_ERROR
}
val resultTime = manager.reportCumulativeTime()
PerformanceCounter.resetAllCounters()
tmp.delete(recursively = true)
totalModules++
return when (result) {
ExitCode.OK -> {
totalPassResult += resultTime
okModules++
ProcessorAction.NEXT
}
else -> ProcessorAction.NEXT
}
}
private inner class CompilerPerformanceManager : CommonCompilerPerformanceManager("Modularized test performance manager") {
fun reportCumulativeTime(): CumulativeTime {
val gcInfo = measurements.filterIsInstance<GarbageCollectionMeasurement>()
.associate { it.garbageCollectionKind to GCInfo(it.garbageCollectionKind, it.milliseconds, it.count) }
val analysisMeasurement = measurements.filterIsInstance<CodeAnalysisMeasurement>().firstOrNull()
val irMeasurements = measurements.filterIsInstance<IRMeasurement>()
return CumulativeTime(
gcInfo,
analysisMeasurement?.milliseconds ?: 0,
irMeasurements.firstOrNull { it.kind == IRMeasurement.Kind.Translation }?.milliseconds ?: 0,
irMeasurements.firstOrNull { it.kind == IRMeasurement.Kind.Generation }?.milliseconds ?: 0,
analysisMeasurement?.files ?: 0,
analysisMeasurement?.lines ?: 0
)
}
}
fun testTotalKotlin() {
for (i in 0 until PASSES) {
println("Pass $i")
runTestOnce(i)
}
}
}

View File

@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.fir.lightTree.fir.modifier.Modifier
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeModifier
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeParameterModifier
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeProjectionModifier
import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.impl.*
@@ -408,6 +409,8 @@ class DeclarationsConverter(
val delegationSpecifiers = superTypeList?.let { convertDelegationSpecifiers(it) }
var delegatedSuperTypeRef: FirTypeRef? = delegationSpecifiers?.delegatedSuperTypeRef
val delegatedConstructorSource: FirLightSourceElement? = delegationSpecifiers?.delegatedConstructorSource
delegationSpecifiers?.delegateFields?.map { declarations += it }
val superTypeCallEntry = delegationSpecifiers?.delegatedConstructorArguments.orEmpty()
val superTypeRefs = mutableListOf<FirTypeRef>()
@@ -449,7 +452,10 @@ class DeclarationsConverter(
superTypeCallEntry = superTypeCallEntry
)
//parse primary constructor
val primaryConstructorWrapper = convertPrimaryConstructor(primaryConstructor, classWrapper, delegatedConstructorSource)
val primaryConstructorWrapper = convertPrimaryConstructor(
primaryConstructor, classWrapper, delegatedConstructorSource,
delegationSpecifiers?.primaryConstructorBody
)
val firPrimaryConstructor = primaryConstructorWrapper?.firConstructor
firPrimaryConstructor?.let { declarations += it }
@@ -503,6 +509,8 @@ class DeclarationsConverter(
var delegatedSuperTypeRef: FirTypeRef? = null
var classBody: LighterASTNode? = null
var delegatedConstructorSource: FirLightSourceElement? = null
var delegateFields: List<FirField>? = null
var primaryConstructorBody: FirBlock? = null
objectLiteral.getChildNodesByType(OBJECT_DECLARATION).first().forEachChildren {
when (it.tokenType) {
MODIFIER_LIST -> modifiers = convertModifierList(it)
@@ -512,6 +520,8 @@ class DeclarationsConverter(
superTypeRefs += it.superTypesRef
superTypeCallEntry += it.delegatedConstructorArguments
delegatedConstructorSource = it.delegatedConstructorSource
delegateFields = it.delegateFields
primaryConstructorBody = it.primaryConstructorBody
}
CLASS_BODY -> classBody = it
}
@@ -537,6 +547,7 @@ class DeclarationsConverter(
this.superTypeRefs += superTypeRefs
typeRef = delegatedSelfType
delegateFields?.map { this.declarations += it }
val classWrapper = ClassWrapper(
SpecialNames.NO_NAME_PROVIDED, modifiers, ClassKind.OBJECT, this,
hasPrimaryConstructor = false,
@@ -547,7 +558,7 @@ class DeclarationsConverter(
superTypeCallEntry = superTypeCallEntry
)
//parse primary constructor
convertPrimaryConstructor(primaryConstructor, classWrapper, delegatedConstructorSource)
convertPrimaryConstructor(primaryConstructor, classWrapper, delegatedConstructorSource, primaryConstructorBody)
?.let { this.declarations += it.firConstructor }
//parse declarations
@@ -666,7 +677,8 @@ class DeclarationsConverter(
private fun convertPrimaryConstructor(
primaryConstructor: LighterASTNode?,
classWrapper: ClassWrapper,
delegatedConstructorSource: FirLightSourceElement?
delegatedConstructorSource: FirLightSourceElement?,
body: FirBlock? = null
): PrimaryConstructor? {
if (primaryConstructor == null && !classWrapper.isEnumEntry() && classWrapper.hasSecondaryConstructor) return null
if (classWrapper.isInterface()) return null
@@ -709,6 +721,7 @@ class DeclarationsConverter(
typeParameters += constructorTypeParametersFromConstructedClass(classWrapper.classBuilder.typeParameters)
this.valueParameters += valueParameters.map { it.firValueParameter }
delegatedConstructor = firDelegatedCall
this.body = body
}, valueParameters
)
}
@@ -1303,7 +1316,9 @@ class DeclarationsConverter(
val delegatedSuperTypeRef: FirTypeRef?,
val superTypesRef: List<FirTypeRef>,
val delegatedConstructorArguments: List<FirExpression>,
val delegatedConstructorSource: FirLightSourceElement?
val delegatedConstructorSource: FirLightSourceElement?,
val delegateFields: List<FirField>,
val primaryConstructorBody: FirBlock?
)
private fun convertDelegationSpecifiers(delegationSpecifiers: LighterASTNode): DelegationSpecifiers {
@@ -1311,6 +1326,9 @@ class DeclarationsConverter(
val superTypeCallEntry = mutableListOf<FirExpression>()
var delegatedSuperTypeRef: FirTypeRef? = null
var delegateConstructorSource: FirLightSourceElement? = null
val delegateFields = mutableListOf<FirField>()
val initializeDelegateStatements = mutableListOf<FirStatement>()
var delegateNumber = 0
delegationSpecifiers.forEachChildren {
when (it.tokenType) {
SUPER_TYPE_ENTRY -> superTypeRefs += convertType(it)
@@ -1320,10 +1338,23 @@ class DeclarationsConverter(
superTypeCallEntry += second
delegateConstructorSource = it.toFirSourceElement()
}
DELEGATED_SUPER_TYPE_ENTRY -> superTypeRefs += convertExplicitDelegation(it)
DELEGATED_SUPER_TYPE_ENTRY -> {
superTypeRefs += convertExplicitDelegation(it, delegateNumber, delegateFields, initializeDelegateStatements)
delegateNumber++
}
}
}
return DelegationSpecifiers(delegatedSuperTypeRef, superTypeRefs, superTypeCallEntry, delegateConstructorSource)
val body = if (initializeDelegateStatements.isNotEmpty()) {
buildBlock {
for (statement in initializeDelegateStatements) {
statements += statement
}
}
} else null
return DelegationSpecifiers(
delegatedSuperTypeRef, superTypeRefs, superTypeCallEntry, delegateConstructorSource,
delegateFields, body
)
}
/**
@@ -1352,7 +1383,12 @@ class DeclarationsConverter(
* : userType "by" element
* ;
*/
private fun convertExplicitDelegation(explicitDelegation: LighterASTNode): FirDelegatedTypeRef {
private fun convertExplicitDelegation(
explicitDelegation: LighterASTNode,
delegateNumber: Int,
delegateFields: MutableList<FirField>,
initializeDelegateStatements: MutableList<FirStatement>
): FirTypeRef {
lateinit var firTypeRef: FirTypeRef
var firExpression: FirExpression? = buildErrorExpression(
explicitDelegation.toFirSourceElement(), ConeSimpleDiagnostic("Should have delegate", DiagnosticKind.Syntax)
@@ -1364,10 +1400,30 @@ class DeclarationsConverter(
}
}
return buildDelegatedTypeRef {
delegate = firExpression
typeRef = firTypeRef
}
val delegateName = Name.identifier("\$\$delegate_$delegateNumber")
delegateFields.add(
buildField {
source = firExpression!!.source
session = baseSession
origin = FirDeclarationOrigin.Synthetic
name = delegateName
returnTypeRef = firTypeRef!!
symbol = FirFieldSymbol(CallableId(name))
isVar = false
status = FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL)
}
)
initializeDelegateStatements.add(
buildVariableAssignment {
source = firExpression!!.source
calleeReference =
buildSimpleNamedReference {
name = delegateName
}
rValue = firExpression!!
}
)
return firTypeRef
}
/***** TYPES *****/

View File

@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
import org.jetbrains.kotlin.fir.references.FirNamedReference
import org.jetbrains.kotlin.fir.references.builder.*
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.types.builder.*
@@ -48,7 +49,6 @@ import org.jetbrains.kotlin.util.OperatorNameConventions
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
import java.util.*
import org.jetbrains.kotlin.utils.addToStdlib.runIf
import kotlin.collections.contains
class RawFirBuilder(
session: FirSession, val baseScopeProvider: FirScopeProvider, val stubMode: Boolean
@@ -459,6 +459,8 @@ class RawFirBuilder(
): FirTypeRef {
var superTypeCallEntry: KtSuperTypeCallEntry? = null
var delegatedSuperTypeRef: FirTypeRef? = null
var delegateNumber = 0
val initializeDelegateStatements = mutableListOf<FirStatement>()
for (superTypeListEntry in superTypeListEntries) {
when (superTypeListEntry) {
is KtSuperTypeEntry -> {
@@ -471,10 +473,32 @@ class RawFirBuilder(
}
is KtDelegatedSuperTypeEntry -> {
val type = superTypeListEntry.typeReference.toFirOrErrorType()
container.superTypeRefs += buildDelegatedTypeRef {
delegate = { superTypeListEntry.delegateExpression }.toFirExpression("Should have delegate")
typeRef = type
val delegateExpression = { superTypeListEntry.delegateExpression }.toFirExpression("Should have delegate")
container.superTypeRefs += type
val delegateName = Name.identifier("\$\$delegate_$delegateNumber")
val delegateSource = superTypeListEntry.delegateExpression?.toFirSourceElement()
val delegateField = buildField {
source = delegateSource
session = baseSession
origin = FirDeclarationOrigin.Synthetic
name = delegateName
returnTypeRef = type
symbol = FirFieldSymbol(CallableId(name))
isVar = false
status = FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL)
}
initializeDelegateStatements.add(
buildVariableAssignment {
source = delegateSource
calleeReference =
buildSimpleNamedReference {
name = delegateName
}
rValue = delegateExpression
}
)
container.declarations.add(delegateField)
delegateNumber ++
}
}
}
@@ -526,8 +550,14 @@ class RawFirBuilder(
delegatedSuperTypeRef,
delegatedSelfTypeRef ?: delegatedSuperTypeRef,
owner = this,
containerTypeParameters
containerTypeParameters,
body = if (initializeDelegateStatements.isNotEmpty()) buildBlock {
for (statement in initializeDelegateStatements) {
statements += statement
}
} else null
)
container.declarations += firPrimaryConstructor
return delegatedSuperTypeRef
}
@@ -537,7 +567,8 @@ class RawFirBuilder(
delegatedSuperTypeRef: FirTypeRef,
delegatedSelfTypeRef: FirTypeRef,
owner: KtClassOrObject,
ownerTypeParameters: List<FirTypeParameterRef>
ownerTypeParameters: List<FirTypeParameterRef>,
body: FirBlock? = null
): FirConstructor {
val constructorCallee = superTypeCallEntry?.calleeExpression?.toFirSourceElement()
val constructorSource = this?.toFirSourceElement()
@@ -577,6 +608,7 @@ class RawFirBuilder(
typeParameters += constructorTypeParametersFromConstructedClass(ownerTypeParameters)
this@toFirConstructor?.extractAnnotationsTo(this)
this@toFirConstructor?.extractValueParametersTo(this)
this.body = body
}
}
@@ -719,7 +751,7 @@ class RawFirBuilder(
classOrObject.extractSuperTypeListEntriesTo(this, delegatedSelfType, null, classKind, typeParameters)
val primaryConstructor = classOrObject.primaryConstructor
val firPrimaryConstructor = declarations.firstOrNull() as? FirConstructor
val firPrimaryConstructor = declarations.firstOrNull {it is FirConstructor} as? FirConstructor
if (primaryConstructor != null && firPrimaryConstructor != null) {
primaryConstructor.valueParameters.zip(
firPrimaryConstructor.valueParameters

View File

@@ -308,7 +308,8 @@ internal fun Candidate.resolveArgument(
private fun Candidate.prepareExpectedType(session: FirSession, argument: FirExpression, parameter: FirValueParameter?): ConeKotlinType? {
if (parameter == null) return null
if (parameter.returnTypeRef is FirILTTypeRefPlaceHolder) return argument.resultType.coneType
if (parameter.returnTypeRef is FirILTTypeRefPlaceHolder && argument.resultType is FirResolvedTypeRef)
return argument.resultType.coneType
val basicExpectedType = argument.getExpectedType(session, parameter/*, LanguageVersionSettings*/)
val expectedType = getExpectedTypeWithSAMConversion(session, argument, basicExpectedType) ?: basicExpectedType
return this.substitutor.substituteOrSelf(expectedType)

View File

@@ -138,6 +138,14 @@ class FirStatusResolveTransformer(
return transformDeclaration(property, data)
}
override fun transformField(
field: FirField,
data: FirDeclarationStatus?
): CompositeTransformResult<FirDeclaration> {
field.transformStatus(this, field.resolveStatus(field.status, containingClass, isLocal = false))
return transformDeclaration(field, data)
}
override fun transformEnumEntry(enumEntry: FirEnumEntry, data: FirDeclarationStatus?): CompositeTransformResult<FirDeclaration> {
return transformDeclaration(enumEntry, data)
}

View File

@@ -741,7 +741,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
else
staticsAndCompanion
val constructor = (owner as? FirRegularClass)?.declarations?.firstOrNull() as? FirConstructor
val constructor = (owner as? FirRegularClass)?.declarations?.firstOrNull { it is FirConstructor } as? FirConstructor
val primaryConstructorParametersScope =
if (constructor?.isPrimary == true) {
constructor.valueParameters.fold(FirLocalScope()) { acc, param -> acc.storeVariable(param) }

View File

@@ -30,7 +30,7 @@ class FirClassDeclaredMemberScope(
when (declaration) {
is FirCallableMemberDeclaration<*> -> {
val name = when (declaration) {
is FirConstructor -> Name.special("<init>")
is FirConstructor -> constructorName
is FirVariable<*> -> declaration.name
is FirSimpleFunction -> declaration.name
else -> continue@loop
@@ -43,6 +43,7 @@ class FirClassDeclaredMemberScope(
}
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
if (name == constructorName) return
val symbols = callablesIndex[name] ?: emptyList()
for (symbol in symbols) {
if (symbol is FirFunctionSymbol<*>) {
@@ -52,7 +53,7 @@ class FirClassDeclaredMemberScope(
}
override fun processDeclaredConstructors(processor: (FirConstructorSymbol) -> Unit) {
val symbols = callablesIndex[Name.special("<init>")] ?: return
val symbols = callablesIndex[constructorName] ?: return
for (symbol in symbols) {
if (symbol is FirConstructorSymbol) {
processor(symbol)
@@ -76,3 +77,6 @@ class FirClassDeclaredMemberScope(
nestedClassifierScope?.processClassifiersByNameWithSubstitution(name, processor)
}
}
private val constructorName = Name.special("<init>")

View File

@@ -9,8 +9,8 @@ import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.fir.declarations.builder.FirRegularClassBuilder
import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParameterBuilder
import org.jetbrains.kotlin.fir.declarations.impl.FirRegularClassImpl
import org.jetbrains.kotlin.fir.declarations.impl.FirFileImpl
import org.jetbrains.kotlin.fir.declarations.impl.FirRegularClassImpl
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
@@ -119,4 +119,7 @@ var FirProperty.isFromVararg: Boolean? by FirDeclarationDataRegistry.data(IsFrom
fun FirAnnotatedDeclaration.hasAnnotation(classId: ClassId): Boolean {
return annotations.any { it.annotationTypeRef.coneTypeSafe<ConeClassLikeType>()?.classId == classId }
}
}
inline val FirDeclaration.isSynthetic: Boolean
get() = origin == FirDeclarationOrigin.Synthetic

View File

@@ -31,7 +31,6 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
import org.jetbrains.kotlin.types.KotlinType
@@ -52,7 +51,6 @@ object JvmArrayVariableInLoopAssignmentChecker : AdditionalTypeChecker {
val resolvedCall = lhsExpression.getResolvedCall(c.trace.bindingContext) ?: return
val variableDescriptor = resolvedCall.resultingDescriptor as? LocalVariableDescriptor ?: return
if (variableDescriptor is SyntheticFieldDescriptor) return
@Suppress("DEPRECATION")
if (variableDescriptor.isDelegated) return
val variableType = variableDescriptor.returnType

View File

@@ -27,7 +27,7 @@ object JvmMultifileClassStateChecker : DeclarationChecker {
if (!JvmFileClassUtil.getFileClassInfoNoResolve(declaration.containingKtFile).withJvmMultifileClass) return
if (@Suppress("DEPRECATION") descriptor.isDelegated ||
if (descriptor.isDelegated ||
context.trace.bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor) == true) {
context.trace.report(ErrorsJvm.STATE_IN_MULTIFILE_CLASS.on(declaration))
}

View File

@@ -108,10 +108,7 @@ public class LocalVariableDescriptor extends VariableDescriptorWithInitializerIm
return setter;
}
// This override is not deprecated because local variables can only come from sources,
// and we can be sure that they won't be recompiled independently
@Override
@SuppressWarnings("deprecation")
public boolean isDelegated() {
return isDelegated;
}

View File

@@ -41,7 +41,6 @@ internal fun VariableDescriptor.variableKind(
return propertyKind(usageModule)
}
@Suppress("DEPRECATION")
if (this is LocalVariableDescriptor && this.isDelegated) {
// Local delegated property: normally unstable, but can be treated as stable in legacy mode
return if (languageVersionSettings.supportsFeature(LanguageFeature.ProhibitSmartcastsOnLocalDelegatedProperty))

View File

@@ -16,9 +16,9 @@
package org.jetbrains.kotlin.backend.common
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.builders.Scope
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.symbols.*
@@ -167,7 +167,7 @@ abstract class IrElementVisitorVoidWithContext : IrElementVisitorVoid {
}
final override fun visitField(declaration: IrField) {
@Suppress("DEPRECATION") val isDelegated = declaration.descriptor.isDelegated
val isDelegated = declaration.descriptor.isDelegated
if (isDelegated) scopeStack.push(createScope(declaration))
visitFieldNew(declaration)
if (isDelegated) scopeStack.pop()

View File

@@ -17,7 +17,10 @@
package org.jetbrains.kotlin.psi2ir.generators
import com.intellij.psi.tree.IElementType
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.descriptors.ValueDescriptor
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor
import org.jetbrains.kotlin.ir.builders.irBlock
@@ -191,7 +194,6 @@ class AssignmentGenerator(statementGenerator: StatementGenerator) : StatementGen
createBackingFieldLValue(ktExpr, descriptor.propertyDescriptor, receiverValue, origin)
}
is LocalVariableDescriptor ->
@Suppress("DEPRECATION")
if (descriptor.isDelegated)
DelegatedLocalPropertyLValue(
context,

View File

@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
import org.jetbrains.kotlin.resolve.descriptorUtil.classValueType
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.KotlinType
import java.util.*
class CallGenerator(statementGenerator: StatementGenerator) : StatementGeneratorExtension(statementGenerator) {
@@ -120,7 +120,6 @@ class CallGenerator(statementGenerator: StatementGenerator) : StatementGenerator
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
origin: IrStatementOrigin? = null
) =
@Suppress("DEPRECATION")
if (descriptor is LocalVariableDescriptor && descriptor.isDelegated) {
val getterDescriptor = descriptor.getter!!
val getterSymbol = context.symbolTable.referenceFunction(getterDescriptor.original)

View File

@@ -22,7 +22,10 @@ import org.jetbrains.kotlin.builtins.isKFunctionType
import org.jetbrains.kotlin.builtins.isKSuspendFunctionType
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
import org.jetbrains.kotlin.ir.declarations.MetadataSource
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
@@ -486,7 +489,6 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St
}
}
@Suppress("DEPRECATION")
private fun getFieldForPropertyReference(originalProperty: PropertyDescriptor) =
// NB this is a hack, we really don't know if an arbitrary property has a backing field or not
when {

View File

@@ -19,7 +19,9 @@ import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.impl.*
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.util.SYNTHETIC_OFFSET
import org.jetbrains.kotlin.ir.util.SymbolTable
import org.jetbrains.kotlin.ir.util.referenceClassifier
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal

View File

@@ -159,15 +159,14 @@ class DeclarationStubGenerator(
val origin = computeOrigin(descriptor)
return symbolTable.declareProperty(
UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor.original,
isDelegated = @Suppress("DEPRECATION") descriptor.isDelegated
UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor.original, descriptor.isDelegated
) {
IrLazyProperty(
UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin,
it, descriptor,
descriptor.name, descriptor.visibility, descriptor.modality,
descriptor.isVar, descriptor.isConst, descriptor.isLateInit,
@Suppress("DEPRECATION") descriptor.isDelegated, descriptor.isEffectivelyExternal(), descriptor.isExpect,
descriptor.isDelegated, descriptor.isEffectivelyExternal(), descriptor.isExpect,
isFakeOverride = (origin == IrDeclarationOrigin.FAKE_OVERRIDE),
stubGenerator = this, typeTranslator = typeTranslator, bindingContext = bindingContext
)

View File

@@ -648,7 +648,7 @@ open class SymbolTable(
endOffset: Int,
origin: IrDeclarationOrigin,
descriptor: PropertyDescriptor,
@Suppress("DEPRECATION") isDelegated: Boolean = descriptor.isDelegated,
isDelegated: Boolean = descriptor.isDelegated,
propertyFactory: (IrPropertySymbol) -> IrProperty = { symbol ->
IrPropertyImpl(
startOffset, endOffset, origin, symbol, isDelegated = isDelegated,

View File

@@ -240,7 +240,7 @@ class DescriptorSerializer private constructor(
ProtoEnumFlags.modality(descriptor.modality),
ProtoEnumFlags.memberKind(descriptor.kind),
descriptor.isVar, hasGetter, hasSetter, hasConstant, descriptor.isConst, descriptor.isLateInit, descriptor.isExternal,
@Suppress("DEPRECATION") descriptor.isDelegated, descriptor.isExpect
descriptor.isDelegated, descriptor.isExpect
)
if (flags != builder.flags) {
builder.flags = flags

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface A<T> {
fun foo(): T
}

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface A<T> {
var result: T
}

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface A<T> {
fun foo(t: T): String
}

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface Trait1 {
fun foo() : String
}

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// Changed when traits were introduced. May not make sense any more
open class X(val x : Int) {}

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
public inline fun Int.times(body : () -> Unit) {
var count = this;

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface A {
fun foo(): Int
}

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface Trait {
fun foo() = "O"
fun bar(): String

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface A {
val result: String
}

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface A {
fun foo(): Int
}

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface A {
fun foo(): String
}

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface A {
fun foo(): String
}

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// FULL_JDK
// WITH_RUNTIME

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
import helpers.*

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// SKIP_JDK6
// TARGET_BACKEND: JVM

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
public interface Base {
fun test() = "base fail"
}

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface A<T> {
fun foo(): T
}

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// SKIP_JDK6
// TARGET_BACKEND: JVM
// FILE: Base.java

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface IFoo {
fun foo(): String
}

View File

@@ -1,5 +1,4 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND_FIR: JVM_IR
interface IFoo {
fun getO(): String

View File

@@ -1,6 +1,5 @@
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
// IGNORE_BACKEND_FIR: JVM_IR
import kotlin.test.assertEquals
interface IFoo {

View File

@@ -1,6 +1,5 @@
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
// IGNORE_BACKEND_FIR: JVM_IR
import kotlin.test.assertEquals
interface IFoo {

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface TextField {
fun getText(): String
fun setText(text: String)

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface FooTrait {
val propertyTest: String
}

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
internal interface A {
fun foo(): String
}

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class Thing(delegate: CharSequence) : CharSequence by delegate
fun box(): String {

View File

@@ -1,6 +1,5 @@
// !LANGUAGE: +DoNotGenerateThrowsForDelegatedKotlinMembers
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// FILE: A.kt

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_RUNTIME

View File

@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// The old backend thinks `toArray(): Array<Int?>` is the same as `toArray(): Array<Any?>`
// IGNORE_BACKEND: JVM

View File

@@ -4,5 +4,5 @@ interface T
annotation class Ann: C()
annotation class Ann2: T
annotation class Ann3: T by a
annotation class Ann3: T by <!ANNOTATION_CLASS_MEMBER!>a<!>
annotation class Ann4: C(), T

View File

@@ -1,3 +1,3 @@
class C : Base1 by Base2(1) {
class C : Base1 by <!UNRESOLVED_REFERENCE!>Base2<!>(1) {
fun test() { }
}

View File

@@ -46,34 +46,59 @@ FILE fqName:<root> fileName:/delegatedGenericImplementation.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[<root>.IBase<E of <root>.Test1>]'
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <B> ($this:<root>.IBase<A of <root>.IBase>, a:E of <root>.Test1, b:B of <root>.Test1.foo) returnType:kotlin.Unit [fake_override]
SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<E of <root>.Test1> visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.Test1<E of <root>.Test1> declared in <root>.Test1' type=<root>.Test1<E of <root>.Test1> origin=null
value: GET_VAR 'i: <root>.IBase<E of <root>.Test1> declared in <root>.Test1.<init>' type=<root>.IBase<E of <root>.Test1> origin=null
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.Test1<E of <root>.Test1>, a:A of <root>.IBase, b:B of <root>.IBase.foo) returnType:kotlin.Unit
overridden:
public abstract fun foo <B> (a: A of <root>.IBase, b: B of <root>.IBase.foo): kotlin.Unit declared in <root>.IBase
TYPE_PARAMETER name:B index:0 variance: superTypes:[kotlin.Any?]
$this: VALUE_PARAMETER name:<this> type:<root>.IBase<A of <root>.IBase>
VALUE_PARAMETER name:a index:0 type:E of <root>.Test1
VALUE_PARAMETER name:b index:1 type:B of <root>.Test1.foo
PROPERTY FAKE_OVERRIDE name:id visibility:public modality:ABSTRACT [fake_override,val]
FUN FAKE_OVERRIDE name:<get-id> visibility:public modality:ABSTRACT <C> ($this:<root>.IBase<A of <root>.IBase>) returnType:kotlin.collections.Map<E of <root>.Test1, C of <root>.Test1.<get-id>>? [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:id visibility:public modality:ABSTRACT [fake_override,val]
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test1<E of <root>.Test1>
VALUE_PARAMETER DELEGATED_MEMBER name:a index:0 type:A of <root>.IBase
VALUE_PARAMETER DELEGATED_MEMBER name:b index:1 type:B of <root>.IBase.foo
BLOCK_BODY
CALL 'public abstract fun foo <B> (a: A of <root>.IBase, b: B of <root>.IBase.foo): kotlin.Unit declared in <root>.IBase' type=kotlin.Unit origin=null
<B>: <none>
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<E of <root>.Test1> visibility:local [final]' type=<root>.IBase<E of <root>.Test1> origin=null
receiver: GET_VAR '<this>: <root>.Test1<E of <root>.Test1> declared in <root>.Test1.foo' type=<root>.Test1<E of <root>.Test1> origin=null
a: GET_VAR 'a: A of <root>.IBase declared in <root>.Test1.foo' type=A of <root>.IBase origin=null
b: GET_VAR 'b: B of <root>.IBase.foo declared in <root>.Test1.foo' type=B of <root>.IBase.foo origin=null
PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val]
FUN DELEGATED_MEMBER name:<get-id> visibility:public modality:OPEN <> ($this:<root>.Test1<E of <root>.Test1>) returnType:kotlin.collections.Map<A of <root>.IBase, C of <root>.IBase.<get-id>>?
correspondingProperty: PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val]
overridden:
public abstract fun <get-id> <C> (): kotlin.collections.Map<A of <root>.IBase, C of <root>.IBase.<get-id>>? declared in <root>.IBase
TYPE_PARAMETER name:C index:0 variance: superTypes:[kotlin.Any?]
$this: VALUE_PARAMETER name:<this> type:<root>.IBase<A of <root>.IBase>
PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var]
FUN FAKE_OVERRIDE name:<get-x> visibility:public modality:ABSTRACT <D> ($this:<root>.IBase<A of <root>.IBase>) returnType:D of <root>.Test1.<get-x>? [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var]
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test1<E of <root>.Test1>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-id> (): kotlin.collections.Map<A of <root>.IBase, C of <root>.IBase.<get-id>>? declared in <root>.Test1'
CALL 'public abstract fun <get-id> <C> (): kotlin.collections.Map<A of <root>.IBase, C of <root>.IBase.<get-id>>? declared in <root>.IBase' type=kotlin.collections.Map<A of <root>.IBase, C of <root>.IBase.<get-id>>? origin=null
<C>: <none>
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<E of <root>.Test1> visibility:local [final]' type=<root>.IBase<E of <root>.Test1> origin=null
receiver: GET_VAR '<this>: <root>.Test1<E of <root>.Test1> declared in <root>.Test1.<get-id>' type=<root>.Test1<E of <root>.Test1> origin=null
PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var]
FUN DELEGATED_MEMBER name:<get-x> visibility:public modality:OPEN <> ($this:<root>.Test1<E of <root>.Test1>) returnType:D of <root>.IBase.<get-x>?
correspondingProperty: PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var]
overridden:
public abstract fun <get-x> <D> (): D of <root>.IBase.<get-x>? declared in <root>.IBase
TYPE_PARAMETER name:D index:0 variance: superTypes:[kotlin.Any?]
$this: VALUE_PARAMETER name:<this> type:<root>.IBase<A of <root>.IBase>
FUN FAKE_OVERRIDE name:<set-x> visibility:public modality:ABSTRACT <D> ($this:<root>.IBase<A of <root>.IBase>, <set-?>:D of <root>.Test1.<set-x>?) returnType:kotlin.Unit [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var]
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test1<E of <root>.Test1>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-x> (): D of <root>.IBase.<get-x>? declared in <root>.Test1'
CALL 'public abstract fun <get-x> <D> (): D of <root>.IBase.<get-x>? declared in <root>.IBase' type=D of <root>.IBase.<get-x>? origin=null
<D>: <none>
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<E of <root>.Test1> visibility:local [final]' type=<root>.IBase<E of <root>.Test1> origin=null
receiver: GET_VAR '<this>: <root>.Test1<E of <root>.Test1> declared in <root>.Test1.<get-x>' type=<root>.Test1<E of <root>.Test1> origin=null
FUN DELEGATED_MEMBER name:<set-x> visibility:public modality:OPEN <> ($this:<root>.Test1<E of <root>.Test1>, <set-?>:D of <root>.IBase.<set-x>?) returnType:kotlin.Unit
correspondingProperty: PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var]
overridden:
public abstract fun <set-x> <D> (<set-?>: D of <root>.IBase.<set-x>?): kotlin.Unit declared in <root>.IBase
TYPE_PARAMETER name:D index:0 variance: superTypes:[kotlin.Any?]
$this: VALUE_PARAMETER name:<this> type:<root>.IBase<A of <root>.IBase>
VALUE_PARAMETER name:<set-?> index:0 type:D of <root>.Test1.<set-x>?
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test1<E of <root>.Test1>
VALUE_PARAMETER DELEGATED_MEMBER name:<set-?> index:0 type:D of <root>.IBase.<set-x>?
BLOCK_BODY
CALL 'public abstract fun <set-x> <D> (<set-?>: D of <root>.IBase.<set-x>?): kotlin.Unit declared in <root>.IBase' type=kotlin.Unit origin=null
<D>: <none>
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<E of <root>.Test1> visibility:local [final]' type=<root>.IBase<E of <root>.Test1> origin=null
receiver: GET_VAR '<this>: <root>.Test1<E of <root>.Test1> declared in <root>.Test1.<set-x>' type=<root>.Test1<E of <root>.Test1> origin=null
<set-?>: GET_VAR '<set-?>: D of <root>.IBase.<set-x>? declared in <root>.Test1.<set-x>' type=D of <root>.IBase.<set-x>? origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<E of <root>.Test1> visibility:local [final]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
@@ -94,6 +119,9 @@ FILE fqName:<root> fileName:/delegatedGenericImplementation.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[<root>.IBase<kotlin.String>]'
SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<kotlin.String> visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2' type=<root>.Test2 origin=null
value: GET_VAR 'j: <root>.IBase<kotlin.String> declared in <root>.Test2.<init>' type=<root>.IBase<kotlin.String> origin=null
PROPERTY name:j visibility:public modality:FINAL [var]
FIELD PROPERTY_BACKING_FIELD name:j type:<root>.IBase<kotlin.String> visibility:private
EXPRESSION_BODY
@@ -113,34 +141,56 @@ FILE fqName:<root> fileName:/delegatedGenericImplementation.kt
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:<root>.IBase<kotlin.String> visibility:private' type=kotlin.Unit origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<set-j>' type=<root>.Test2 origin=null
value: GET_VAR '<set-?>: <root>.IBase<kotlin.String> declared in <root>.Test2.<set-j>' type=<root>.IBase<kotlin.String> origin=null
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <B> ($this:<root>.IBase<A of <root>.IBase>, a:kotlin.String, b:B of <root>.Test2.foo) returnType:kotlin.Unit [fake_override]
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.Test2, a:A of <root>.IBase, b:B of <root>.IBase.foo) returnType:kotlin.Unit
overridden:
public abstract fun foo <B> (a: A of <root>.IBase, b: B of <root>.IBase.foo): kotlin.Unit declared in <root>.IBase
TYPE_PARAMETER name:B index:0 variance: superTypes:[kotlin.Any?]
$this: VALUE_PARAMETER name:<this> type:<root>.IBase<A of <root>.IBase>
VALUE_PARAMETER name:a index:0 type:kotlin.String
VALUE_PARAMETER name:b index:1 type:B of <root>.Test2.foo
PROPERTY FAKE_OVERRIDE name:id visibility:public modality:ABSTRACT [fake_override,val]
FUN FAKE_OVERRIDE name:<get-id> visibility:public modality:ABSTRACT <C> ($this:<root>.IBase<A of <root>.IBase>) returnType:kotlin.collections.Map<kotlin.String, C of <root>.Test2.<get-id>>? [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:id visibility:public modality:ABSTRACT [fake_override,val]
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
VALUE_PARAMETER DELEGATED_MEMBER name:a index:0 type:A of <root>.IBase
VALUE_PARAMETER DELEGATED_MEMBER name:b index:1 type:B of <root>.IBase.foo
BLOCK_BODY
CALL 'public abstract fun foo <B> (a: A of <root>.IBase, b: B of <root>.IBase.foo): kotlin.Unit declared in <root>.IBase' type=kotlin.Unit origin=null
<B>: <none>
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<kotlin.String> visibility:local [final]' type=<root>.IBase<kotlin.String> origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.foo' type=<root>.Test2 origin=null
a: GET_VAR 'a: A of <root>.IBase declared in <root>.Test2.foo' type=A of <root>.IBase origin=null
b: GET_VAR 'b: B of <root>.IBase.foo declared in <root>.Test2.foo' type=B of <root>.IBase.foo origin=null
PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val]
FUN DELEGATED_MEMBER name:<get-id> visibility:public modality:OPEN <> ($this:<root>.Test2) returnType:kotlin.collections.Map<A of <root>.IBase, C of <root>.IBase.<get-id>>?
correspondingProperty: PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val]
overridden:
public abstract fun <get-id> <C> (): kotlin.collections.Map<A of <root>.IBase, C of <root>.IBase.<get-id>>? declared in <root>.IBase
TYPE_PARAMETER name:C index:0 variance: superTypes:[kotlin.Any?]
$this: VALUE_PARAMETER name:<this> type:<root>.IBase<A of <root>.IBase>
PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var]
FUN FAKE_OVERRIDE name:<get-x> visibility:public modality:ABSTRACT <D> ($this:<root>.IBase<A of <root>.IBase>) returnType:D of <root>.Test2.<get-x>? [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var]
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-id> (): kotlin.collections.Map<A of <root>.IBase, C of <root>.IBase.<get-id>>? declared in <root>.Test2'
CALL 'public abstract fun <get-id> <C> (): kotlin.collections.Map<A of <root>.IBase, C of <root>.IBase.<get-id>>? declared in <root>.IBase' type=kotlin.collections.Map<A of <root>.IBase, C of <root>.IBase.<get-id>>? origin=null
<C>: <none>
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<kotlin.String> visibility:local [final]' type=<root>.IBase<kotlin.String> origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<get-id>' type=<root>.Test2 origin=null
PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var]
FUN DELEGATED_MEMBER name:<get-x> visibility:public modality:OPEN <> ($this:<root>.Test2) returnType:D of <root>.IBase.<get-x>?
correspondingProperty: PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var]
overridden:
public abstract fun <get-x> <D> (): D of <root>.IBase.<get-x>? declared in <root>.IBase
TYPE_PARAMETER name:D index:0 variance: superTypes:[kotlin.Any?]
$this: VALUE_PARAMETER name:<this> type:<root>.IBase<A of <root>.IBase>
FUN FAKE_OVERRIDE name:<set-x> visibility:public modality:ABSTRACT <D> ($this:<root>.IBase<A of <root>.IBase>, <set-?>:D of <root>.Test2.<set-x>?) returnType:kotlin.Unit [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var]
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-x> (): D of <root>.IBase.<get-x>? declared in <root>.Test2'
CALL 'public abstract fun <get-x> <D> (): D of <root>.IBase.<get-x>? declared in <root>.IBase' type=D of <root>.IBase.<get-x>? origin=null
<D>: <none>
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<kotlin.String> visibility:local [final]' type=<root>.IBase<kotlin.String> origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<get-x>' type=<root>.Test2 origin=null
FUN DELEGATED_MEMBER name:<set-x> visibility:public modality:OPEN <> ($this:<root>.Test2, <set-?>:D of <root>.IBase.<set-x>?) returnType:kotlin.Unit
correspondingProperty: PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var]
overridden:
public abstract fun <set-x> <D> (<set-?>: D of <root>.IBase.<set-x>?): kotlin.Unit declared in <root>.IBase
TYPE_PARAMETER name:D index:0 variance: superTypes:[kotlin.Any?]
$this: VALUE_PARAMETER name:<this> type:<root>.IBase<A of <root>.IBase>
VALUE_PARAMETER name:<set-?> index:0 type:D of <root>.Test2.<set-x>?
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
VALUE_PARAMETER DELEGATED_MEMBER name:<set-?> index:0 type:D of <root>.IBase.<set-x>?
BLOCK_BODY
CALL 'public abstract fun <set-x> <D> (<set-?>: D of <root>.IBase.<set-x>?): kotlin.Unit declared in <root>.IBase' type=kotlin.Unit origin=null
<D>: <none>
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<kotlin.String> visibility:local [final]' type=<root>.IBase<kotlin.String> origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<set-x>' type=<root>.Test2 origin=null
<set-?>: GET_VAR '<set-?>: D of <root>.IBase.<set-x>? declared in <root>.Test2.<set-x>' type=D of <root>.IBase.<set-x>? origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<kotlin.String> visibility:local [final]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any

View File

@@ -200,21 +200,39 @@ FILE fqName:<root> fileName:/delegatedImplementation.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[<root>.IBase]'
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IBase, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit [fake_override]
SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.Test1 declared in <root>.Test1' type=<root>.Test1 origin=null
value: GET_OBJECT 'CLASS OBJECT name:BaseImpl modality:FINAL visibility:public superTypes:[<root>.IBase]' type=<root>.BaseImpl
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.Test1, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit
overridden:
public abstract fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase
VALUE_PARAMETER name:x index:0 type:kotlin.Int
VALUE_PARAMETER name:s index:1 type:kotlin.String
FUN FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT <> ($this:<root>.IBase) returnType:kotlin.Int [fake_override]
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test1
VALUE_PARAMETER DELEGATED_MEMBER name:x index:0 type:kotlin.Int
VALUE_PARAMETER DELEGATED_MEMBER name:s index:1 type:kotlin.String
BLOCK_BODY
CALL 'public abstract fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in <root>.IBase' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase visibility:local [final]' type=<root>.IBase origin=null
receiver: GET_VAR '<this>: <root>.Test1 declared in <root>.Test1.foo' type=<root>.Test1 origin=null
x: GET_VAR 'x: kotlin.Int declared in <root>.Test1.foo' type=kotlin.Int origin=null
s: GET_VAR 's: kotlin.String declared in <root>.Test1.foo' type=kotlin.String origin=null
FUN DELEGATED_MEMBER name:bar visibility:public modality:OPEN <> ($this:<root>.Test1) returnType:kotlin.Int
overridden:
public abstract fun bar (): kotlin.Int declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase
FUN FAKE_OVERRIDE name:qux visibility:public modality:ABSTRACT <> ($this:<root>.IBase, $receiver:kotlin.String) returnType:kotlin.Unit [fake_override]
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test1
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun bar (): kotlin.Int declared in <root>.Test1'
CALL 'public abstract fun bar (): kotlin.Int declared in <root>.IBase' type=kotlin.Int origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase visibility:local [final]' type=<root>.IBase origin=null
receiver: GET_VAR '<this>: <root>.Test1 declared in <root>.Test1.bar' type=<root>.Test1 origin=null
FUN DELEGATED_MEMBER name:qux visibility:public modality:OPEN <> ($this:<root>.Test1) returnType:kotlin.Unit
overridden:
public abstract fun qux (): kotlin.Unit declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test1
BLOCK_BODY
CALL 'public abstract fun qux (): kotlin.Unit declared in <root>.IBase' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase visibility:local [final]' type=<root>.IBase origin=null
receiver: GET_VAR '<this>: <root>.Test1 declared in <root>.Test1.qux' type=<root>.Test1 origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.IBase visibility:local [final]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
@@ -234,21 +252,111 @@ FILE fqName:<root> fileName:/delegatedImplementation.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[<root>.IBase; <root>.IOther]'
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IBase, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit [fake_override]
SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2' type=<root>.Test2 origin=null
value: GET_OBJECT 'CLASS OBJECT name:BaseImpl modality:FINAL visibility:public superTypes:[<root>.IBase]' type=<root>.BaseImpl
SET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:<root>.IOther visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2' type=<root>.Test2 origin=null
value: CALL 'public final fun otherImpl (x0: kotlin.String, y0: kotlin.Int): <root>.IOther declared in <root>' type=<root>.IOther origin=null
x0: CONST String type=kotlin.String value=""
y0: CONST Int type=kotlin.Int value=42
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.Test2, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit
overridden:
public abstract fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase
VALUE_PARAMETER name:x index:0 type:kotlin.Int
VALUE_PARAMETER name:s index:1 type:kotlin.String
FUN FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT <> ($this:<root>.IBase) returnType:kotlin.Int [fake_override]
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
VALUE_PARAMETER DELEGATED_MEMBER name:x index:0 type:kotlin.Int
VALUE_PARAMETER DELEGATED_MEMBER name:s index:1 type:kotlin.String
BLOCK_BODY
CALL 'public abstract fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in <root>.IBase' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase visibility:local [final]' type=<root>.IBase origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.foo' type=<root>.Test2 origin=null
x: GET_VAR 'x: kotlin.Int declared in <root>.Test2.foo' type=kotlin.Int origin=null
s: GET_VAR 's: kotlin.String declared in <root>.Test2.foo' type=kotlin.String origin=null
FUN DELEGATED_MEMBER name:bar visibility:public modality:OPEN <> ($this:<root>.Test2) returnType:kotlin.Int
overridden:
public abstract fun bar (): kotlin.Int declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase
FUN FAKE_OVERRIDE name:qux visibility:public modality:ABSTRACT <> ($this:<root>.IBase, $receiver:kotlin.String) returnType:kotlin.Unit [fake_override]
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun bar (): kotlin.Int declared in <root>.Test2'
CALL 'public abstract fun bar (): kotlin.Int declared in <root>.IBase' type=kotlin.Int origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase visibility:local [final]' type=<root>.IBase origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.bar' type=<root>.Test2 origin=null
FUN DELEGATED_MEMBER name:qux visibility:public modality:OPEN <> ($this:<root>.Test2) returnType:kotlin.Unit
overridden:
public abstract fun qux (): kotlin.Unit declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
BLOCK_BODY
CALL 'public abstract fun qux (): kotlin.Unit declared in <root>.IBase' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase visibility:local [final]' type=<root>.IBase origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.qux' type=<root>.Test2 origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.IBase visibility:local [final]
PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [val]
FUN DELEGATED_MEMBER name:<get-x> visibility:public modality:OPEN <> ($this:<root>.Test2) returnType:kotlin.String
correspondingProperty: PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [val]
overridden:
public abstract fun <get-x> (): kotlin.String declared in <root>.IOther
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-x> (): kotlin.String declared in <root>.Test2'
CALL 'public abstract fun <get-x> (): kotlin.String declared in <root>.IOther' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:<root>.IOther visibility:local [final]' type=<root>.IOther origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<get-x>' type=<root>.Test2 origin=null
PROPERTY DELEGATED_MEMBER name:y visibility:public modality:OPEN [var]
FUN DELEGATED_MEMBER name:<get-y> visibility:public modality:OPEN <> ($this:<root>.Test2) returnType:kotlin.Int
correspondingProperty: PROPERTY DELEGATED_MEMBER name:y visibility:public modality:OPEN [var]
overridden:
public abstract fun <get-y> (): kotlin.Int declared in <root>.IOther
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-y> (): kotlin.Int declared in <root>.Test2'
CALL 'public abstract fun <get-y> (): kotlin.Int declared in <root>.IOther' type=kotlin.Int origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:<root>.IOther visibility:local [final]' type=<root>.IOther origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<get-y>' type=<root>.Test2 origin=null
FUN DELEGATED_MEMBER name:<set-y> visibility:public modality:OPEN <> ($this:<root>.Test2, <set-?>:kotlin.Int) returnType:kotlin.Unit
correspondingProperty: PROPERTY DELEGATED_MEMBER name:y visibility:public modality:OPEN [var]
overridden:
public abstract fun <set-y> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.IOther
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
VALUE_PARAMETER DELEGATED_MEMBER name:<set-?> index:0 type:kotlin.Int
BLOCK_BODY
CALL 'public abstract fun <set-y> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.IOther' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:<root>.IOther visibility:local [final]' type=<root>.IOther origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<set-y>' type=<root>.Test2 origin=null
<set-?>: GET_VAR '<set-?>: kotlin.Int declared in <root>.Test2.<set-y>' type=kotlin.Int origin=null
PROPERTY DELEGATED_MEMBER name:z1 visibility:public modality:OPEN [val]
FUN DELEGATED_MEMBER name:<get-z1> visibility:public modality:OPEN <> ($this:<root>.Test2) returnType:kotlin.Int
correspondingProperty: PROPERTY DELEGATED_MEMBER name:z1 visibility:public modality:OPEN [val]
overridden:
public abstract fun <get-z1> (): kotlin.Int declared in <root>.IOther
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-z1> (): kotlin.Int declared in <root>.Test2'
CALL 'public abstract fun <get-z1> (): kotlin.Int declared in <root>.IOther' type=kotlin.Int origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:<root>.IOther visibility:local [final]' type=<root>.IOther origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<get-z1>' type=<root>.Test2 origin=null
PROPERTY DELEGATED_MEMBER name:z2 visibility:public modality:OPEN [var]
FUN DELEGATED_MEMBER name:<get-z2> visibility:public modality:OPEN <> ($this:<root>.Test2) returnType:kotlin.Int
correspondingProperty: PROPERTY DELEGATED_MEMBER name:z2 visibility:public modality:OPEN [var]
overridden:
public abstract fun <get-z2> (): kotlin.Int declared in <root>.IOther
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-z2> (): kotlin.Int declared in <root>.Test2'
CALL 'public abstract fun <get-z2> (): kotlin.Int declared in <root>.IOther' type=kotlin.Int origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:<root>.IOther visibility:local [final]' type=<root>.IOther origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<get-z2>' type=<root>.Test2 origin=null
FUN DELEGATED_MEMBER name:<set-z2> visibility:public modality:OPEN <> ($this:<root>.Test2, <set-?>:kotlin.Int) returnType:kotlin.Unit
correspondingProperty: PROPERTY DELEGATED_MEMBER name:z2 visibility:public modality:OPEN [var]
overridden:
public abstract fun <set-z2> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.IOther
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
VALUE_PARAMETER DELEGATED_MEMBER name:<set-?> index:0 type:kotlin.Int
BLOCK_BODY
CALL 'public abstract fun <set-z2> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.IOther' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:<root>.IOther visibility:local [final]' type=<root>.IOther origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<set-z2>' type=<root>.Test2 origin=null
<set-?>: GET_VAR '<set-?>: kotlin.Int declared in <root>.Test2.<set-z2>' type=kotlin.Int origin=null
FIELD DELEGATE name:$$delegate_1 type:<root>.IOther visibility:local [final]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
@@ -262,39 +370,3 @@ FILE fqName:<root> fileName:/delegatedImplementation.kt
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,val]
FUN FAKE_OVERRIDE name:<get-x> visibility:public modality:ABSTRACT <> ($this:<root>.IOther) returnType:kotlin.String [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,val]
overridden:
public abstract fun <get-x> (): kotlin.String declared in <root>.IOther
$this: VALUE_PARAMETER name:<this> type:<root>.IOther
PROPERTY FAKE_OVERRIDE name:y visibility:public modality:ABSTRACT [fake_override,var]
FUN FAKE_OVERRIDE name:<get-y> visibility:public modality:ABSTRACT <> ($this:<root>.IOther) returnType:kotlin.Int [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:y visibility:public modality:ABSTRACT [fake_override,var]
overridden:
public abstract fun <get-y> (): kotlin.Int declared in <root>.IOther
$this: VALUE_PARAMETER name:<this> type:<root>.IOther
FUN FAKE_OVERRIDE name:<set-y> visibility:public modality:ABSTRACT <> ($this:<root>.IOther, <set-?>:kotlin.Int) returnType:kotlin.Unit [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:y visibility:public modality:ABSTRACT [fake_override,var]
overridden:
public abstract fun <set-y> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.IOther
$this: VALUE_PARAMETER name:<this> type:<root>.IOther
VALUE_PARAMETER name:<set-?> index:0 type:kotlin.Int
PROPERTY FAKE_OVERRIDE name:z1 visibility:public modality:ABSTRACT [fake_override,val]
FUN FAKE_OVERRIDE name:<get-z1> visibility:public modality:ABSTRACT <> ($this:<root>.IOther) returnType:kotlin.Int [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:z1 visibility:public modality:ABSTRACT [fake_override,val]
overridden:
public abstract fun <get-z1> (): kotlin.Int declared in <root>.IOther
$this: VALUE_PARAMETER name:<this> type:<root>.IOther
PROPERTY FAKE_OVERRIDE name:z2 visibility:public modality:ABSTRACT [fake_override,var]
FUN FAKE_OVERRIDE name:<get-z2> visibility:public modality:ABSTRACT <> ($this:<root>.IOther) returnType:kotlin.Int [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:z2 visibility:public modality:ABSTRACT [fake_override,var]
overridden:
public abstract fun <get-z2> (): kotlin.Int declared in <root>.IOther
$this: VALUE_PARAMETER name:<this> type:<root>.IOther
FUN FAKE_OVERRIDE name:<set-z2> visibility:public modality:ABSTRACT <> ($this:<root>.IOther, <set-?>:kotlin.Int) returnType:kotlin.Unit [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:z2 visibility:public modality:ABSTRACT [fake_override,var]
overridden:
public abstract fun <set-z2> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.IOther
$this: VALUE_PARAMETER name:<this> type:<root>.IOther
VALUE_PARAMETER name:<set-?> index:0 type:kotlin.Int

View File

@@ -53,15 +53,23 @@ FILE fqName:<root> fileName:/delegatedImplementationWithExplicitOverride.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.IFooBar]'
SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFooBar visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.C declared in <root>.C' type=<root>.C origin=null
value: GET_OBJECT 'CLASS OBJECT name:FooBarImpl modality:FINAL visibility:public superTypes:[<root>.IFooBar]' type=<root>.FooBarImpl
FUN name:bar visibility:public modality:FINAL <> ($this:<root>.C) returnType:kotlin.Unit
overridden:
public abstract fun bar (): kotlin.Unit declared in <root>.IFooBar
$this: VALUE_PARAMETER name:<this> type:<root>.C
BLOCK_BODY
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IFooBar) returnType:kotlin.Unit [fake_override]
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.C) returnType:kotlin.Unit
overridden:
public abstract fun foo (): kotlin.Unit declared in <root>.IFooBar
$this: VALUE_PARAMETER name:<this> type:<root>.IFooBar
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.C
BLOCK_BODY
CALL 'public abstract fun foo (): kotlin.Unit declared in <root>.IFooBar' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFooBar visibility:local [final]' type=<root>.IFooBar origin=null
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.foo' type=<root>.C origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.IFooBar visibility:local [final]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any

View File

@@ -123,10 +123,19 @@ FILE fqName:<root> fileName:/implicitNotNullOnDelegatedImplementation.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestJFoo modality:FINAL visibility:public superTypes:[<root>.IFoo]'
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IFoo) returnType:kotlin.String [fake_override]
SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.TestJFoo declared in <root>.TestJFoo' type=<root>.TestJFoo origin=null
value: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.JFoo' type=<root>.JFoo origin=null
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.TestJFoo) returnType:kotlin.String
overridden:
public abstract fun foo (): kotlin.String declared in <root>.IFoo
$this: VALUE_PARAMETER name:<this> type:<root>.IFoo
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.TestJFoo
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.TestJFoo'
CALL 'public abstract fun foo (): kotlin.String declared in <root>.IFoo' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]' type=<root>.IFoo origin=null
receiver: GET_VAR '<this>: <root>.TestJFoo declared in <root>.TestJFoo.foo' type=<root>.TestJFoo origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
@@ -146,10 +155,19 @@ FILE fqName:<root> fileName:/implicitNotNullOnDelegatedImplementation.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK1 modality:FINAL visibility:public superTypes:[<root>.IFoo]'
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IFoo) returnType:kotlin.String [fake_override]
SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.TestK1 declared in <root>.TestK1' type=<root>.TestK1 origin=null
value: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.K1' type=<root>.K1 origin=null
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.TestK1) returnType:kotlin.String
overridden:
public abstract fun foo (): kotlin.String declared in <root>.IFoo
$this: VALUE_PARAMETER name:<this> type:<root>.IFoo
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.TestK1
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.TestK1'
CALL 'public abstract fun foo (): kotlin.String declared in <root>.IFoo' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]' type=<root>.IFoo origin=null
receiver: GET_VAR '<this>: <root>.TestK1 declared in <root>.TestK1.foo' type=<root>.TestK1 origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
@@ -169,10 +187,19 @@ FILE fqName:<root> fileName:/implicitNotNullOnDelegatedImplementation.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK2 modality:FINAL visibility:public superTypes:[<root>.IFoo]'
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IFoo) returnType:kotlin.String [fake_override]
SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.TestK2 declared in <root>.TestK2' type=<root>.TestK2 origin=null
value: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.K2' type=<root>.K2 origin=null
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.TestK2) returnType:kotlin.String
overridden:
public abstract fun foo (): kotlin.String declared in <root>.IFoo
$this: VALUE_PARAMETER name:<this> type:<root>.IFoo
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.TestK2
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.TestK2'
CALL 'public abstract fun foo (): kotlin.String declared in <root>.IFoo' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]' type=<root>.IFoo origin=null
receiver: GET_VAR '<this>: <root>.TestK2 declared in <root>.TestK2.foo' type=<root>.TestK2 origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
@@ -192,10 +219,19 @@ FILE fqName:<root> fileName:/implicitNotNullOnDelegatedImplementation.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK3 modality:FINAL visibility:public superTypes:[<root>.IFoo]'
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IFoo) returnType:kotlin.String [fake_override]
SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.TestK3 declared in <root>.TestK3' type=<root>.TestK3 origin=null
value: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.K3' type=<root>.K3 origin=null
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.TestK3) returnType:kotlin.String
overridden:
public abstract fun foo (): kotlin.String declared in <root>.IFoo
$this: VALUE_PARAMETER name:<this> type:<root>.IFoo
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.TestK3
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.TestK3'
CALL 'public abstract fun foo (): kotlin.String declared in <root>.IFoo' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]' type=<root>.IFoo origin=null
receiver: GET_VAR '<this>: <root>.TestK3 declared in <root>.TestK3.foo' type=<root>.TestK3 origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
@@ -215,10 +251,19 @@ FILE fqName:<root> fileName:/implicitNotNullOnDelegatedImplementation.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK4 modality:FINAL visibility:public superTypes:[<root>.IFoo]'
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IFoo) returnType:kotlin.String [fake_override]
SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.TestK4 declared in <root>.TestK4' type=<root>.TestK4 origin=null
value: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.K4' type=<root>.K4 origin=null
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.TestK4) returnType:kotlin.String
overridden:
public abstract fun foo (): kotlin.String declared in <root>.IFoo
$this: VALUE_PARAMETER name:<this> type:<root>.IFoo
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.TestK4
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.TestK4'
CALL 'public abstract fun foo (): kotlin.String declared in <root>.IFoo' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]' type=<root>.IFoo origin=null
receiver: GET_VAR '<this>: <root>.TestK4 declared in <root>.TestK4.foo' type=<root>.TestK4 origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:local [final]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any

View File

@@ -30,12 +30,22 @@ FILE fqName:<root> fileName:/kt35550.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[<root>.I]'
PROPERTY FAKE_OVERRIDE name:id visibility:public modality:OPEN [fake_override,val]
FUN FAKE_OVERRIDE name:<get-id> visibility:public modality:OPEN <> ($this:<root>.I) returnType:T of <root>.I.<get-id> [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:id visibility:public modality:OPEN [fake_override,val]
SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.I visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.A declared in <root>.A' type=<root>.A origin=null
value: GET_VAR 'i: <root>.I declared in <root>.A.<init>' type=<root>.I origin=null
PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val]
FUN DELEGATED_MEMBER name:<get-id> visibility:public modality:OPEN <> ($this:<root>.A) returnType:T of <root>.I.<get-id>
correspondingProperty: PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val]
overridden:
public open fun <get-id> <T> (): T of <root>.I.<get-id> declared in <root>.I
$this: VALUE_PARAMETER name:<this> type:<root>.I
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.A
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-id> (): T of <root>.I.<get-id> declared in <root>.A'
CALL 'public open fun <get-id> <T> (): T of <root>.I.<get-id> declared in <root>.I' type=T of <root>.I.<get-id> origin=null
<T>: <none>
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.I visibility:local [final]' type=<root>.I origin=null
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-id>' type=<root>.A origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.I visibility:local [final]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any

View File

@@ -35,24 +35,44 @@ FILE fqName:<root> fileName:/delegatedMembers.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[<root>.IBase<TT of <root>.Test>]'
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IBase<T of <root>.IBase>, x:kotlin.Int) returnType:kotlin.Unit [fake_override]
SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<TT of <root>.Test> visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.Test<TT of <root>.Test> declared in <root>.Test' type=<root>.Test<TT of <root>.Test> origin=null
value: GET_VAR 'impl: <root>.IBase<TT of <root>.Test> declared in <root>.Test.<init>' type=<root>.IBase<TT of <root>.Test> origin=null
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.Test<TT of <root>.Test>, x:kotlin.Int) returnType:kotlin.Unit
overridden:
public abstract fun foo (x: kotlin.Int): kotlin.Unit declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase<T of <root>.IBase>
VALUE_PARAMETER name:x index:0 type:kotlin.Int
PROPERTY FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT [fake_override,val]
FUN FAKE_OVERRIDE name:<get-bar> visibility:public modality:ABSTRACT <> ($this:<root>.IBase<T of <root>.IBase>) returnType:kotlin.Int [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT [fake_override,val]
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test<TT of <root>.Test>
VALUE_PARAMETER DELEGATED_MEMBER name:x index:0 type:kotlin.Int
BLOCK_BODY
CALL 'public abstract fun foo (x: kotlin.Int): kotlin.Unit declared in <root>.IBase' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<TT of <root>.Test> visibility:local [final]' type=<root>.IBase<TT of <root>.Test> origin=null
receiver: GET_VAR '<this>: <root>.Test<TT of <root>.Test> declared in <root>.Test.foo' type=<root>.Test<TT of <root>.Test> origin=null
x: GET_VAR 'x: kotlin.Int declared in <root>.Test.foo' type=kotlin.Int origin=null
PROPERTY DELEGATED_MEMBER name:bar visibility:public modality:OPEN [val]
FUN DELEGATED_MEMBER name:<get-bar> visibility:public modality:OPEN <> ($this:<root>.Test<TT of <root>.Test>) returnType:kotlin.Int
correspondingProperty: PROPERTY DELEGATED_MEMBER name:bar visibility:public modality:OPEN [val]
overridden:
public abstract fun <get-bar> (): kotlin.Int declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase<T of <root>.IBase>
FUN FAKE_OVERRIDE name:qux visibility:public modality:ABSTRACT <X> ($this:<root>.IBase<T of <root>.IBase>, t:TT of <root>.Test, x:X of <root>.Test.qux) returnType:kotlin.Unit [fake_override]
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test<TT of <root>.Test>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-bar> (): kotlin.Int declared in <root>.Test'
CALL 'public abstract fun <get-bar> (): kotlin.Int declared in <root>.IBase' type=kotlin.Int origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<TT of <root>.Test> visibility:local [final]' type=<root>.IBase<TT of <root>.Test> origin=null
receiver: GET_VAR '<this>: <root>.Test<TT of <root>.Test> declared in <root>.Test.<get-bar>' type=<root>.Test<TT of <root>.Test> origin=null
FUN DELEGATED_MEMBER name:qux visibility:public modality:OPEN <> ($this:<root>.Test<TT of <root>.Test>, t:T of <root>.IBase, x:X of <root>.IBase.qux) returnType:kotlin.Unit
overridden:
public abstract fun qux <X> (t: T of <root>.IBase, x: X of <root>.IBase.qux): kotlin.Unit declared in <root>.IBase
TYPE_PARAMETER name:X index:0 variance: superTypes:[kotlin.Any?]
$this: VALUE_PARAMETER name:<this> type:<root>.IBase<T of <root>.IBase>
VALUE_PARAMETER name:t index:0 type:TT of <root>.Test
VALUE_PARAMETER name:x index:1 type:X of <root>.Test.qux
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test<TT of <root>.Test>
VALUE_PARAMETER DELEGATED_MEMBER name:t index:0 type:T of <root>.IBase
VALUE_PARAMETER DELEGATED_MEMBER name:x index:1 type:X of <root>.IBase.qux
BLOCK_BODY
CALL 'public abstract fun qux <X> (t: T of <root>.IBase, x: X of <root>.IBase.qux): kotlin.Unit declared in <root>.IBase' type=kotlin.Unit origin=null
<X>: <none>
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<TT of <root>.Test> visibility:local [final]' type=<root>.IBase<TT of <root>.Test> origin=null
receiver: GET_VAR '<this>: <root>.Test<TT of <root>.Test> declared in <root>.Test.qux' type=<root>.Test<TT of <root>.Test> origin=null
t: GET_VAR 't: T of <root>.IBase declared in <root>.Test.qux' type=T of <root>.IBase origin=null
x: GET_VAR 'x: X of <root>.IBase.qux declared in <root>.Test.qux' type=X of <root>.IBase.qux origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.IBase<TT of <root>.Test> visibility:local [final]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any

View File

@@ -452,15 +452,23 @@ private fun RTableContext.printMeasureAsTable(measure: FirResolveBench.Measure,
timeCell(measure.gcTime, inputUnit = TableTimeUnit.MS)
cell(measure.gcCollections.toString())
run {
val linePerSec = statistics.totalLines / TableTimeUnit.S.convert(time, TableTimeUnit.NS)
val df = DecimalFormat().apply {
maximumFractionDigits = 1
isGroupingUsed = true
}
cell(df.format(linePerSec))
}
linePerSecondCell(statistics.totalLines, time, timeUnit = TableTimeUnit.NS)
}
}
fun RTableContext.RTableRowContext.linePerSecondCell(linePerSec: Double) {
val df = DecimalFormat().apply {
maximumFractionDigits = 1
isGroupingUsed = true
}
cell(df.format(linePerSec))
}
fun RTableContext.RTableRowContext.linePerSecondCell(lines: Int, time: Long, timeUnit: TableTimeUnit = TableTimeUnit.NS) {
val linePerSec = lines / TableTimeUnit.S.convert(time, from = timeUnit)
linePerSecondCell(linePerSec)
}
class FirRuntimeException(override val message: String, override val cause: Throwable) : RuntimeException(message, cause)

View File

@@ -120,7 +120,7 @@ class RTableContext {
}
internal enum class TableTimeUnit(val postfixText: String, val nsMultiplier: Double, val fractionDigits: Int) {
enum class TableTimeUnit(val postfixText: String, val nsMultiplier: Double, val fractionDigits: Int) {
NS("ns", 1.0, 0),
MICS("mcs", 1e-3, 3),
MS("ms", 1e-6, 6),
@@ -131,7 +131,16 @@ internal enum class TableTimeUnit(val postfixText: String, val nsMultiplier: Dou
}
}
internal inline fun RTableContext.RTableRowContext.timeCell(
inline class TableTimeUnitConversion(val value: Double) {
infix fun to(dest: TableTimeUnit): Double {
return value * dest.nsMultiplier
}
}
infix fun Long.from(from: TableTimeUnit) = TableTimeUnitConversion(this / from.nsMultiplier)
inline fun RTableContext.RTableRowContext.timeCell(
time: Long,
outputUnit: TableTimeUnit = TableTimeUnit.MS,
inputUnit: TableTimeUnit = TableTimeUnit.NS,
@@ -144,6 +153,6 @@ internal inline fun RTableContext.RTableRowContext.timeCell(
cell("${df.format(outputUnit.convert(time, inputUnit))} ${outputUnit.postfixText}")
}
internal inline fun printTable(out: Appendable = System.out, body: RTableContext.() -> Unit) {
inline fun printTable(out: Appendable = System.out, body: RTableContext.() -> Unit) {
RTableContext().apply(body).printout(out)
}

View File

@@ -25,10 +25,10 @@ interface VariableDescriptorWithAccessors : VariableDescriptor {
* Please be careful with this method. Depending on the fact that a property is delegated may be dangerous in the compiler.
* Whether or not a property is delegated is neither the API or the ABI of that property, and one should be able to recompile a library
* in a way that makes some non-delegated properties delegated or vice versa, without any problems at compilation time or at runtime.
* So this method should not be used in the compiler frontend in a way that would significantly alter the compilation result.
*
* This flag is needed for reflection however, that's why it's serialized to metadata and is exposed in this interface.
*/
@Deprecated("Do not call this method in the compiler front-end.")
val isDelegated: Boolean
}

View File

@@ -173,7 +173,7 @@ class DeserializedPropertyDescriptor(
): PropertyDescriptorImpl {
return DeserializedPropertyDescriptor(
newOwner, original, annotations, newModality, newVisibility, isVar, newName, kind, isLateInit, isConst, isExternal,
@Suppress("DEPRECATION") isDelegated, isExpect, proto, nameResolver, typeTable, versionRequirementTable, containerSource
isDelegated, isExpect, proto, nameResolver, typeTable, versionRequirementTable, containerSource
)
}

View File

@@ -79,7 +79,7 @@ internal abstract class KPropertyImpl<out V> private constructor(
val javaField: Field? get() = _javaField()
protected fun computeDelegateField(): Field? =
if (@Suppress("DEPRECATION") descriptor.isDelegated) javaField else null
if (descriptor.isDelegated) javaField else null
protected fun getDelegate(field: Field?, receiver: Any?): Any? =
try {

View File

@@ -1041,6 +1041,10 @@ fun main(args: Array<String>) {
testClass<AbstractScratchLineMarkersTest> {
model("scratch/lineMarker", testMethod = "doScratchTest", pattern = KT_OR_KTS)
}
testClass<AbstractScriptTemplatesFromDependenciesTest> {
model("script/templatesFromDependencies", extension = null, recursive = false)
}
}
testGroup("idea/idea-maven/test", "idea/idea-maven/testData") {

View File

@@ -119,10 +119,7 @@ import org.jetbrains.kotlin.idea.repl.AbstractIdeReplCompletionTest
import org.jetbrains.kotlin.idea.resolve.*
import org.jetbrains.kotlin.idea.scratch.AbstractScratchLineMarkersTest
import org.jetbrains.kotlin.idea.scratch.AbstractScratchRunActionTest
import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationCompletionTest
import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationHighlightingTest
import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationNavigationTest
import org.jetbrains.kotlin.idea.script.AbstractScriptDefinitionsOrderTest
import org.jetbrains.kotlin.idea.script.*
import org.jetbrains.kotlin.idea.slicer.AbstractSlicerLeafGroupingTest
import org.jetbrains.kotlin.idea.slicer.AbstractSlicerNullnessGroupingTest
import org.jetbrains.kotlin.idea.slicer.AbstractSlicerTreeTest
@@ -841,20 +838,60 @@ fun main(args: Array<String>) {
testGroup("idea/scripting-support/test", "idea/scripting-support/testData") {
testClass<AbstractScratchRunActionTest> {
model("scratch", extension = "kts", testMethod = "doScratchCompilingTest", testClassName = "ScratchCompiling", recursive = false)
model(
"scratch",
extension = "kts",
testMethod = "doScratchCompilingTest",
testClassName = "ScratchCompiling",
recursive = false
)
model("scratch", extension = "kts", testMethod = "doScratchReplTest", testClassName = "ScratchRepl", recursive = false)
model("scratch/multiFile", extension = null, testMethod = "doScratchMultiFileTest", testClassName = "ScratchMultiFile", recursive = false)
model(
"scratch/multiFile",
extension = null,
testMethod = "doScratchMultiFileTest",
testClassName = "ScratchMultiFile",
recursive = false
)
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetCompilingTest", testClassName = "WorksheetCompiling", recursive = false)
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetReplTest", testClassName = "WorksheetRepl", recursive = false)
model("worksheet/multiFile", extension = null, testMethod = "doWorksheetMultiFileTest", testClassName = "WorksheetMultiFile", recursive = false)
model(
"worksheet",
extension = "ws.kts",
testMethod = "doWorksheetCompilingTest",
testClassName = "WorksheetCompiling",
recursive = false
)
model(
"worksheet",
extension = "ws.kts",
testMethod = "doWorksheetReplTest",
testClassName = "WorksheetRepl",
recursive = false
)
model(
"worksheet/multiFile",
extension = null,
testMethod = "doWorksheetMultiFileTest",
testClassName = "WorksheetMultiFile",
recursive = false
)
model("scratch/rightPanelOutput", extension = "kts", testMethod = "doRightPreviewPanelOutputTest", testClassName = "ScratchRightPanelOutput", recursive = false)
model(
"scratch/rightPanelOutput",
extension = "kts",
testMethod = "doRightPreviewPanelOutputTest",
testClassName = "ScratchRightPanelOutput",
recursive = false
)
}
testClass<AbstractScratchLineMarkersTest> {
model("scratch/lineMarker", testMethod = "doScratchTest", pattern = KT_OR_KTS)
}
testClass<AbstractScriptTemplatesFromDependenciesTest> {
model("script/templatesFromDependencies", extension = null, recursive = false)
}
}
/*

View File

@@ -119,10 +119,7 @@ import org.jetbrains.kotlin.idea.repl.AbstractIdeReplCompletionTest
import org.jetbrains.kotlin.idea.resolve.*
import org.jetbrains.kotlin.idea.scratch.AbstractScratchLineMarkersTest
import org.jetbrains.kotlin.idea.scratch.AbstractScratchRunActionTest
import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationCompletionTest
import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationHighlightingTest
import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationNavigationTest
import org.jetbrains.kotlin.idea.script.AbstractScriptDefinitionsOrderTest
import org.jetbrains.kotlin.idea.script.*
import org.jetbrains.kotlin.idea.slicer.AbstractSlicerLeafGroupingTest
import org.jetbrains.kotlin.idea.slicer.AbstractSlicerNullnessGroupingTest
import org.jetbrains.kotlin.idea.slicer.AbstractSlicerTreeTest
@@ -841,20 +838,60 @@ fun main(args: Array<String>) {
testGroup("idea/scripting-support/test", "idea/scripting-support/testData") {
testClass<AbstractScratchRunActionTest> {
model("scratch", extension = "kts", testMethod = "doScratchCompilingTest", testClassName = "ScratchCompiling", recursive = false)
model(
"scratch",
extension = "kts",
testMethod = "doScratchCompilingTest",
testClassName = "ScratchCompiling",
recursive = false
)
model("scratch", extension = "kts", testMethod = "doScratchReplTest", testClassName = "ScratchRepl", recursive = false)
model("scratch/multiFile", extension = null, testMethod = "doScratchMultiFileTest", testClassName = "ScratchMultiFile", recursive = false)
model(
"scratch/multiFile",
extension = null,
testMethod = "doScratchMultiFileTest",
testClassName = "ScratchMultiFile",
recursive = false
)
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetCompilingTest", testClassName = "WorksheetCompiling", recursive = false)
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetReplTest", testClassName = "WorksheetRepl", recursive = false)
model("worksheet/multiFile", extension = null, testMethod = "doWorksheetMultiFileTest", testClassName = "WorksheetMultiFile", recursive = false)
model(
"worksheet",
extension = "ws.kts",
testMethod = "doWorksheetCompilingTest",
testClassName = "WorksheetCompiling",
recursive = false
)
model(
"worksheet",
extension = "ws.kts",
testMethod = "doWorksheetReplTest",
testClassName = "WorksheetRepl",
recursive = false
)
model(
"worksheet/multiFile",
extension = null,
testMethod = "doWorksheetMultiFileTest",
testClassName = "WorksheetMultiFile",
recursive = false
)
model("scratch/rightPanelOutput", extension = "kts", testMethod = "doRightPreviewPanelOutputTest", testClassName = "ScratchRightPanelOutput", recursive = false)
model(
"scratch/rightPanelOutput",
extension = "kts",
testMethod = "doRightPreviewPanelOutputTest",
testClassName = "ScratchRightPanelOutput",
recursive = false
)
}
testClass<AbstractScratchLineMarkersTest> {
model("scratch/lineMarker", testMethod = "doScratchTest", pattern = KT_OR_KTS)
}
testClass<AbstractScriptTemplatesFromDependenciesTest> {
model("script/templatesFromDependencies", extension = null, recursive = false)
}
}
/*

View File

@@ -16,7 +16,6 @@ import com.intellij.openapi.diagnostic.ControlFlowException
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.extensions.Extensions
import com.intellij.openapi.fileTypes.FileTypeManager
import com.intellij.openapi.progress.runBackgroundableTask
import com.intellij.openapi.project.Project
import com.intellij.openapi.projectRoots.JavaSdk
import com.intellij.openapi.projectRoots.ex.PathUtilEx
@@ -76,6 +75,8 @@ class LoadScriptDefinitionsStartupActivity : StartupActivity {
class ScriptDefinitionsManager(private val project: Project) : LazyScriptDefinitionProvider() {
private var definitionsBySource = mutableMapOf<ScriptDefinitionsSource, List<ScriptDefinition>>()
@Volatile
private var definitions: List<ScriptDefinition>? = null
private val failedContributorsHashes = HashSet<Int>()
@@ -121,21 +122,26 @@ class ScriptDefinitionsManager(private val project: Project) : LazyScriptDefinit
override fun findScriptDefinition(fileName: String): KotlinScriptDefinition? = findDefinition(File(fileName).toScriptSource())?.legacyDefinition
fun reloadDefinitionsBy(source: ScriptDefinitionsSource) = lock.write {
fun reloadDefinitionsBy(source: ScriptDefinitionsSource) {
if (definitions == null) return // not loaded yet
if (source !in definitionsBySource) error("Unknown script definition source: $source")
lock.write {
if (source !in definitionsBySource) error("Unknown script definition source: $source")
}
definitionsBySource[source] = source.safeGetDefinitions()
val safeGetDefinitions = source.safeGetDefinitions()
lock.write {
definitionsBySource[source] = safeGetDefinitions
definitions = definitionsBySource.values.flattenTo(mutableListOf())
definitions = definitionsBySource.values.flattenTo(mutableListOf())
updateDefinitions()
updateDefinitions()
}
}
override val currentDefinitions
get() =
(definitions ?: kotlin.run {
(definitions ?: run {
reloadScriptDefinitions()
definitions!!
}).asSequence().filter { KotlinScriptingSettings.getInstance(project).isScriptDefinitionEnabled(it) }
@@ -149,45 +155,46 @@ class ScriptDefinitionsManager(private val project: Project) : LazyScriptDefinit
return fromNewEp.dropLast(1) + fromDeprecatedEP + fromNewEp.last()
}
fun reloadScriptDefinitionsIfNeeded() = lock.write {
if (definitions == null) {
loadScriptDefinitions()
}
fun reloadScriptDefinitionsIfNeeded() {
definitions ?: loadScriptDefinitions()
}
fun reloadScriptDefinitions() = lock.write {
loadScriptDefinitions()
}
fun reloadScriptDefinitions() = loadScriptDefinitions()
private fun loadScriptDefinitions() {
for (source in getSources()) {
val definitions = source.safeGetDefinitions()
definitionsBySource[source] = definitions
val newDefinitionsBySource = getSources().map { it to it.safeGetDefinitions() }.toMap()
lock.write {
definitionsBySource.putAll(newDefinitionsBySource)
definitions = definitionsBySource.values.flattenTo(mutableListOf())
updateDefinitions()
}
definitions = definitionsBySource.values.flattenTo(mutableListOf())
updateDefinitions()
}
fun reorderScriptDefinitions() = lock.write {
fun reorderScriptDefinitions() {
definitions?.forEach {
it.order = KotlinScriptingSettings.getInstance(project).getScriptDefinitionOrder(it)
val order = KotlinScriptingSettings.getInstance(project).getScriptDefinitionOrder(it)
lock.write {
it.order = order
}
}
definitions = definitions?.sortedBy { it.order }
lock.write {
definitions = definitions?.sortedBy { it.order }
updateDefinitions()
updateDefinitions()
}
}
fun getAllDefinitions(): List<ScriptDefinition> {
return definitions ?: kotlin.run {
reloadScriptDefinitions()
definitions!!
}
fun getAllDefinitions(): List<ScriptDefinition> = definitions ?: run {
reloadScriptDefinitions()
definitions!!
}
fun isReady(): Boolean {
return definitions != null && definitionsBySource.keys.all { source ->
if (definitions == null) return false
val keys = lock.write { definitionsBySource.keys }
return keys.all { source ->
// TODO: implement another API for readiness checking
(source as? ScriptDefinitionContributor)?.isReady() != false
}

View File

@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor
import org.jetbrains.kotlin.idea.debugger.evaluate.*
import org.jetbrains.kotlin.idea.debugger.evaluate.DebuggerFieldPropertyDescriptor
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinCodeFragmentFactory.Companion.FAKE_JAVA_CONTEXT_FUNCTION_NAME
import org.jetbrains.kotlin.idea.debugger.evaluate.compilation.CodeFragmentParameter.*
import org.jetbrains.kotlin.idea.debugger.safeLocation
@@ -313,11 +312,8 @@ class CodeFragmentParameterAnalyzer(
val isLValue = unwrappedExpression?.let { isAssignmentLValue(it) } ?: false
parameters.getOrPut(target) {
val type = target.type
@Suppress("DEPRECATION")
val kind = if (target is LocalVariableDescriptor && target.isDelegated) Kind.DELEGATED else Kind.ORDINARY
Smart(Dumb(kind, target.name.asString()), type, target, isLValue)
Smart(Dumb(kind, target.name.asString()), target.type, target, isLValue)
}
}
else -> null

View File

@@ -0,0 +1,143 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.idea.script
import com.intellij.ide.projectView.actions.MarkRootActionBase
import com.intellij.openapi.module.JavaModuleType
import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.project.guessProjectDir
import com.intellij.openapi.roots.*
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VfsUtil
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.testFramework.HeavyPlatformTestCase
import com.intellij.testFramework.PsiTestUtil
import com.intellij.util.indexing.FileBasedIndex
import org.jetbrains.jps.model.java.JavaResourceRootType
import org.jetbrains.kotlin.idea.core.script.ScriptDefinitionContributor
import org.jetbrains.kotlin.idea.util.application.runWriteAction
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import org.jetbrains.kotlin.test.JUnit3RunnerWithInnersForJPS
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.MockLibraryUtil
import org.jetbrains.kotlin.test.util.addDependency
import org.jetbrains.kotlin.test.util.jarRoot
import org.jetbrains.kotlin.test.util.projectLibrary
import org.junit.runner.RunWith
import java.io.File
@RunWith(JUnit3RunnerWithInnersForJPS::class)
abstract class AbstractScriptTemplatesFromDependenciesTest : HeavyPlatformTestCase() {
companion object {
private const val testFileName = "test.kts"
}
fun doTest(path: String) {
val projectRoot = project.guessProjectDir() ?: return
val testDataDir = File(path)
copyDirContentsTo(
LocalFileSystem.getInstance().findFileByIoFile(testDataDir)!!,
projectRoot
)
testDataDir
.listFiles { f -> f.name.startsWith("module") }
?.filter { it.exists() }
?.forEach {
createTestModule(it)
}
ModuleManager.getInstance(project).modules.forEach { module ->
testDataDir
.listFiles { f -> f.name.startsWith("jar") }
?.map { folder ->
ModuleRootManager.getInstance(module).modifiableModel.apply {
val vFile = VfsUtil.findFileByIoFile(folder, true)!!
MarkRootActionBase.findContentEntry(this, vFile)?.addExcludeFolder(vFile)
runWriteAction { this@apply.commit() }
}
packJar(folder)
}
?.forEach { jar ->
module.addDependency(
projectLibrary(
libraryName = "script-library",
classesRoot = jar.jarRoot
)
)
}
}
val roots: Collection<VirtualFile> = FileBasedIndex.getInstance().getContainingFiles(
ScriptTemplatesClassRootsIndex.NAME,
Unit,
GlobalSearchScope.allScope(project)
)
val testFile = File(path, testFileName)
val fileText = testFile.readText()
checkRoots(fileText, roots)
val provider = ScriptDefinitionContributor.find<ScriptTemplatesFromDependenciesProvider>(project)
?: error("Cannot find ScriptTemplatesFromDependenciesProvider")
val (templates, classpath) = provider.getTemplateClassPath(roots.toList())
checkTemplateNames(fileText, templates)
checkTemplateClasspath(fileText, classpath)
}
private fun String.removeTestDirPrefix(): String = this.substringAfterLast(getTestName(true))
private fun checkRoots(fileText: String, roots: Collection<VirtualFile>) {
val actual = roots.map { it.path.removeTestDirPrefix() }
val expected = InTextDirectivesUtils.findListWithPrefixes(fileText, "// ROOT:")
assertOrderedEquals("Roots are different", actual.sorted(), expected.sorted())
}
private fun checkTemplateNames(fileText: String, names: Collection<String>) {
val expected = InTextDirectivesUtils.findListWithPrefixes(fileText, "// NAME:")
assertOrderedEquals("Template names are different", names.sorted(), expected.sorted())
}
private fun checkTemplateClasspath(fileText: String, classpath: Collection<File>) {
val actual = classpath.map {
FileUtil.toSystemIndependentName(it.path).removeTestDirPrefix()
}
val expected = InTextDirectivesUtils.findListWithPrefixes(fileText, "// CLASSPATH:")
assertOrderedEquals("Roots are different", actual.sorted(), expected.sorted())
}
private fun createTestModule(dir: File): Module {
val newModule = createModuleAt(name, project, JavaModuleType.getModuleType(), dir.path)
dir.listFiles()?.forEach {
val root = VfsUtil.findFileByIoFile(it, true) ?: return@forEach
when (it.name) {
"src" -> PsiTestUtil.addSourceRoot(newModule, root)
"test" -> PsiTestUtil.addSourceRoot(newModule, root, true)
"resources" -> PsiTestUtil.addSourceRoot(newModule, root, JavaResourceRootType.RESOURCE)
}
}
return newModule
}
private fun packJar(dir: File): File {
val contentDir = KotlinTestUtils.tmpDirForReusableFolder("folderForLibrary-${getTestName(true)}")
return MockLibraryUtil.createJarFile(contentDir, dir, "templates")
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.idea.script;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
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/scripting-support/testData/script/templatesFromDependencies")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class ScriptTemplatesFromDependenciesTestGenerated extends AbstractScriptTemplatesFromDependenciesTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInTemplatesFromDependencies() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/scripting-support/testData/script/templatesFromDependencies"), Pattern.compile("^([^\\.]+)$"), null, false);
}
@TestMetadata("inJar")
public void testInJar() throws Exception {
runTest("idea/scripting-support/testData/script/templatesFromDependencies/inJar/");
}
@TestMetadata("inTests")
public void testInTests() throws Exception {
runTest("idea/scripting-support/testData/script/templatesFromDependencies/inTests/");
}
@TestMetadata("multipleRoots")
public void testMultipleRoots() throws Exception {
runTest("idea/scripting-support/testData/script/templatesFromDependencies/multipleRoots/");
}
@TestMetadata("multipleTemplates")
public void testMultipleTemplates() throws Exception {
runTest("idea/scripting-support/testData/script/templatesFromDependencies/multipleTemplates/");
}
@TestMetadata("outsideRoots")
public void testOutsideRoots() throws Exception {
runTest("idea/scripting-support/testData/script/templatesFromDependencies/outsideRoots/");
}
@TestMetadata("singleTemplate")
public void testSingleTemplate() throws Exception {
runTest("idea/scripting-support/testData/script/templatesFromDependencies/singleTemplate/");
}
}

View File

@@ -0,0 +1 @@
// needed for module creation

View File

@@ -0,0 +1,8 @@
// ROOT: /templates.jar!/META-INF/kotlin/script/templates/MyTemplate1.classname
// ROOT: /templates.jar!/inner/META-INF/kotlin/script/templates/MyTemplate2.classname
// NAME: MyTemplate1
// CLASSPATH: /templates.jar

View File

@@ -0,0 +1 @@
// ROOT: /module/test/META-INF/kotlin/script/templates/MyTemplate.classname

Some files were not shown because too many files have changed in this diff Show More