diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index 196f6d0eea2..9d2c945c9c8 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -126,6 +126,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/classes/enumWithSecondaryCtor.kt"); } + @TestMetadata("implicitNotNullOnDelegatedImplementation.kt") + public void testImplicitNotNullOnDelegatedImplementation() throws Exception { + runTest("compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.kt"); + } + @TestMetadata("initBlock.kt") public void testInitBlock() throws Exception { runTest("compiler/testData/ir/irText/classes/initBlock.kt"); diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt index 3a3afab13cb..a1edeabfe8a 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt @@ -41,6 +41,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.renderer.DescriptorRendererModifier import org.jetbrains.kotlin.renderer.OverrideRenderingPolicy import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.DelegationResolver import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.propertyIfAccessor import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter @@ -142,8 +143,8 @@ class ClassGenerator( private fun generateFakeOverrideMemberDeclarations(irClass: IrClass, ktClassOrObject: KtPureClassOrObject) { irClass.descriptor.unsubstitutedMemberScope.getContributedDescriptors() .mapNotNull { - it.safeAs().takeIf { - it?.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE + it.safeAs().takeIf { memberDescriptor -> + memberDescriptor?.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE } } .sortedByRenderer() @@ -154,31 +155,25 @@ class ClassGenerator( private fun generateMembersDeclaredInSupertypeList(irClass: IrClass, ktClassOrObject: KtClassOrObject) { val ktSuperTypeList = ktClassOrObject.getSuperTypeList() ?: return - val delegatedMembers = irClass.descriptor.unsubstitutedMemberScope - .getContributedDescriptors(DescriptorKindFilter.CALLABLES) - .filterIsInstance() - .filter { it.kind == CallableMemberDescriptor.Kind.DELEGATION } - .sortedByRenderer() - if (delegatedMembers.isEmpty()) return - for (ktEntry in ktSuperTypeList.entries) { if (ktEntry is KtDelegatedSuperTypeEntry) { - generateDelegatedImplementationMembers(irClass, ktEntry, delegatedMembers) + generateDelegatedImplementationMembers(irClass, ktEntry) } } } private fun generateDelegatedImplementationMembers( irClass: IrClass, - ktEntry: KtDelegatedSuperTypeEntry, - delegatedMembers: List + ktEntry: KtDelegatedSuperTypeEntry ) { val ktDelegateExpression = ktEntry.delegateExpression!! val delegateType = getTypeInferredByFrontendOrFail(ktDelegateExpression) val superType = getOrFail(BindingContext.TYPE, ktEntry.typeReference!!) + val superTypeConstructorDescriptor = superType.constructor.declarationDescriptor val superClass = superTypeConstructorDescriptor as? ClassDescriptor ?: throw AssertionError("Unexpected supertype constructor for delegation: $superTypeConstructorDescriptor") + val delegateDescriptor = IrImplementingDelegateDescriptorImpl(irClass.descriptor, delegateType, superType) val irDelegateField = context.symbolTable.declareField( ktDelegateExpression.startOffsetSkippingComments, ktDelegateExpression.endOffset, @@ -188,10 +183,17 @@ class ClassGenerator( ) irClass.addMember(irDelegateField) + val delegatesMap = DelegationResolver.getDelegates(irClass.descriptor, superClass, delegateType) + val delegatedMembers = delegatesMap.keys.toList().sortedByRenderer() + for (delegatedMember in delegatedMembers) { val overriddenMember = delegatedMember.overriddenDescriptors.find { it.containingDeclaration.original == superClass.original } if (overriddenMember != null) { - generateDelegatedMember(irClass, irDelegateField, delegatedMember, overriddenMember) + val delegateToMember = delegatesMap[delegatedMember] + ?: throw AssertionError( + "No corresponding member in delegate type $delegateType for $delegatedMember overriding $overriddenMember" + ) + generateDelegatedMember(irClass, irDelegateField, delegatedMember, delegateToMember) } } } @@ -200,30 +202,27 @@ class ClassGenerator( irClass: IrClass, irDelegate: IrField, delegatedMember: CallableMemberDescriptor, - overriddenMember: CallableMemberDescriptor + delegateToMember: CallableMemberDescriptor ) { when (delegatedMember) { - is FunctionDescriptor -> - generateDelegatedFunction(irClass, irDelegate, delegatedMember, overriddenMember as FunctionDescriptor) - is PropertyDescriptor -> - generateDelegatedProperty(irClass, irDelegate, delegatedMember, overriddenMember as PropertyDescriptor) + is FunctionDescriptor -> generateDelegatedFunction(irClass, irDelegate, delegatedMember, delegateToMember as FunctionDescriptor) + is PropertyDescriptor -> generateDelegatedProperty(irClass, irDelegate, delegatedMember, delegateToMember as PropertyDescriptor) } - } private fun generateDelegatedProperty( irClass: IrClass, irDelegate: IrField, - delegated: PropertyDescriptor, - overridden: PropertyDescriptor + delegatedDescriptor: PropertyDescriptor, + delegateToDescriptor: PropertyDescriptor ) { - irClass.addMember(generateDelegatedProperty(irDelegate, delegated, overridden)) + irClass.addMember(generateDelegatedProperty(irDelegate, delegatedDescriptor, delegateToDescriptor)) } private fun generateDelegatedProperty( irDelegate: IrField, delegatedDescriptor: PropertyDescriptor, - overriddenDescriptor: PropertyDescriptor + delegateToDescriptor: PropertyDescriptor ): IrProperty { val startOffset = irDelegate.startOffset val endOffset = irDelegate.endOffset @@ -233,10 +232,10 @@ class ClassGenerator( delegatedDescriptor ) - irProperty.getter = generateDelegatedFunction(irDelegate, delegatedDescriptor.getter!!, overriddenDescriptor.getter!!) + irProperty.getter = generateDelegatedFunction(irDelegate, delegatedDescriptor.getter!!, delegateToDescriptor.getter!!) if (delegatedDescriptor.isVar) { - irProperty.setter = generateDelegatedFunction(irDelegate, delegatedDescriptor.setter!!, overriddenDescriptor.setter!!) + irProperty.setter = generateDelegatedFunction(irDelegate, delegatedDescriptor.setter!!, delegateToDescriptor.setter!!) } return irProperty } @@ -244,74 +243,82 @@ class ClassGenerator( private fun generateDelegatedFunction( irClass: IrClass, irDelegate: IrField, - delegated: FunctionDescriptor, - overridden: FunctionDescriptor + delegatedDescriptor: FunctionDescriptor, + delegateToDescriptor: FunctionDescriptor ) { - irClass.addMember(generateDelegatedFunction(irDelegate, delegated, overridden)) + irClass.addMember(generateDelegatedFunction(irDelegate, delegatedDescriptor, delegateToDescriptor)) } private fun generateDelegatedFunction( irDelegate: IrField, - delegated: FunctionDescriptor, - overridden: FunctionDescriptor + delegatedDescriptor: FunctionDescriptor, + delegateToDescriptor: FunctionDescriptor ): IrSimpleFunction = context.symbolTable.declareSimpleFunctionWithOverrides( irDelegate.startOffset, irDelegate.endOffset, IrDeclarationOrigin.DELEGATED_MEMBER, - delegated + delegatedDescriptor ).buildWithScope { irFunction -> FunctionGenerator(declarationGenerator).generateSyntheticFunctionParameterDeclarations(irFunction) // TODO could possibly refer to scoped type parameters for property accessors - irFunction.returnType = delegated.returnType!!.toIrType() + irFunction.returnType = delegatedDescriptor.returnType!!.toIrType() - irFunction.body = generateDelegateFunctionBody(irDelegate, delegated, overridden, irFunction) + irFunction.body = generateDelegateFunctionBody(irDelegate, delegatedDescriptor, delegateToDescriptor, irFunction) } private fun generateDelegateFunctionBody( irDelegate: IrField, - delegated: FunctionDescriptor, - overridden: FunctionDescriptor, + delegatedDescriptor: FunctionDescriptor, + delegateToDescriptor: FunctionDescriptor, irDelegatedFunction: IrSimpleFunction ): IrBlockBodyImpl { val startOffset = irDelegate.startOffset val endOffset = irDelegate.endOffset + val irBlockBody = IrBlockBodyImpl(startOffset, endOffset) - val substitutedOverridden = substituteOverriddenDescriptorForDelegate(delegated, overridden) - val returnType = substitutedOverridden.returnType!! - val irReturnType = returnType.toIrType() - val originalSymbol = context.symbolTable.referenceFunction(overridden.original) + + val substitutedDelegateTo = substituteDelegateToDescriptor(delegatedDescriptor, delegateToDescriptor) + val returnType = substitutedDelegateTo.returnType!! + + val delegateToSymbol = context.symbolTable.referenceFunction(delegateToDescriptor.original) + val irCall = IrCallImpl( - startOffset, endOffset, irReturnType, - originalSymbol, - substitutedOverridden.typeParametersCount + startOffset, endOffset, + returnType.toIrType(), + delegateToSymbol, + substitutedDelegateTo.typeParametersCount ).apply { - context.callToSubstitutedDescriptorMap[this] = substitutedOverridden - val typeArguments = getTypeArgumentsForOverriddenDescriptorDelegatingCall(delegated, overridden) + context.callToSubstitutedDescriptorMap[this] = substitutedDelegateTo + + val typeArguments = getTypeArgumentsForOverriddenDescriptorDelegatingCall(delegatedDescriptor, delegateToDescriptor) putTypeArguments(typeArguments) { it.toIrType() } - } - val dispatchReceiverParameter = irDelegatedFunction.dispatchReceiverParameter!! - val dispatchReceiverType = dispatchReceiverParameter.type - irCall.dispatchReceiver = - IrGetFieldImpl( - startOffset, endOffset, - irDelegate.symbol, - irDelegate.type, - IrGetValueImpl( + + val dispatchReceiverParameter = irDelegatedFunction.dispatchReceiverParameter!! + dispatchReceiver = + IrGetFieldImpl( startOffset, endOffset, - dispatchReceiverType, - dispatchReceiverParameter.symbol + irDelegate.symbol, + irDelegate.type, + IrGetValueImpl( + startOffset, endOffset, + dispatchReceiverParameter.type, + dispatchReceiverParameter.symbol + ) ) - ) - irCall.extensionReceiver = - irDelegatedFunction.extensionReceiverParameter?.let { extensionReceiver -> - IrGetValueImpl(startOffset, endOffset, extensionReceiver.type, extensionReceiver.symbol) + + extensionReceiver = + irDelegatedFunction.extensionReceiverParameter?.let { extensionReceiver -> + IrGetValueImpl(startOffset, endOffset, extensionReceiver.type, extensionReceiver.symbol) + } + + mapValueParameters { overriddenValueParameter -> + val delegatedValueParameter = delegatedDescriptor.valueParameters[overriddenValueParameter.index] + val irDelegatedValueParameter = irDelegatedFunction.getIrValueParameter(delegatedValueParameter) + IrGetValueImpl(startOffset, endOffset, irDelegatedValueParameter.type, irDelegatedValueParameter.symbol) } - irCall.mapValueParameters { overriddenValueParameter -> - val delegatedValueParameter = delegated.valueParameters[overriddenValueParameter.index] - val irDelegatedValueParameter = irDelegatedFunction.getIrValueParameter(delegatedValueParameter) - IrGetValueImpl(startOffset, endOffset, irDelegatedValueParameter.type, irDelegatedValueParameter.symbol) } + if (KotlinBuiltIns.isUnit(returnType) || KotlinBuiltIns.isNothing(returnType)) { irBlockBody.statements.add(irCall) } else { @@ -322,22 +329,23 @@ class ClassGenerator( } @Suppress("UNCHECKED_CAST") - private fun substituteOverriddenDescriptorForDelegate(delegated: D, overridden: D): D = - // PropertyAccessorDescriptor doesn't support 'substitute' right now, so we substitute the corresponding property instead. + private fun substituteDelegateToDescriptor(delegated: D, overridden: D): D = + // PropertyAccessorDescriptor doesn't support 'substitute', so we substitute the corresponding property instead. when (overridden) { - is PropertyGetterDescriptor -> substituteOverriddenDescriptorForDelegate( + is PropertyGetterDescriptor -> substituteDelegateToDescriptor( (delegated as PropertyGetterDescriptor).correspondingProperty, overridden.correspondingProperty ).getter as D - is PropertySetterDescriptor -> substituteOverriddenDescriptorForDelegate( + is PropertySetterDescriptor -> substituteDelegateToDescriptor( (delegated as PropertySetterDescriptor).correspondingProperty, overridden.correspondingProperty ).setter as D else -> { + val delegatedTypeParameters = delegated.typeParameters val substitutor = TypeSubstitutor.create( overridden.typeParameters.associate { - val delegatedDefaultType = delegated.typeParameters[it.index].defaultType + val delegatedDefaultType = delegatedTypeParameters[it.index].defaultType it.typeConstructor to TypeProjectionImpl(delegatedDefaultType) } ) @@ -346,13 +354,13 @@ class ClassGenerator( } private fun getTypeArgumentsForOverriddenDescriptorDelegatingCall( - delegated: FunctionDescriptor, - overridden: FunctionDescriptor + delegatedDescriptor: FunctionDescriptor, + delegateToDescriptor: FunctionDescriptor ): Map? { - val keys = overridden.propertyIfAccessor.original.typeParameters + val keys = delegateToDescriptor.propertyIfAccessor.original.typeParameters if (keys.isEmpty()) return null - val values = delegated.propertyIfAccessor.typeParameters + val values = delegatedDescriptor.propertyIfAccessor.typeParameters val typeArguments = newHashMapWithExpectedSize(keys.size) for ((i, overriddenTypeParameter) in keys.withIndex()) { diff --git a/compiler/testData/codegen/boxAgainstJava/notNullAssertions/delegation.kt b/compiler/testData/codegen/boxAgainstJava/notNullAssertions/delegation.kt index 4b16c770283..2274ebd2326 100644 --- a/compiler/testData/codegen/boxAgainstJava/notNullAssertions/delegation.kt +++ b/compiler/testData/codegen/boxAgainstJava/notNullAssertions/delegation.kt @@ -1,15 +1,4 @@ -// IGNORE_BACKEND: JVM_IR -// FILE: Delegation.java - -public class Delegation { - public static class ReturnNull { - public String foo() { - return null; - } - } -} - -// FILE: 1.kt +// FILE: delegation.kt interface Tr { fun foo(): String @@ -19,8 +8,7 @@ class DelegateTo : Delegation.ReturnNull(), Tr { override fun foo() = super.foo() } -class DelegateFrom : Tr by DelegateTo() { -} +class DelegateFrom : Tr by DelegateTo() fun box(): String { try { @@ -31,3 +19,13 @@ fun box(): String { return "OK" } } + +// FILE: Delegation.java + +public class Delegation { + public static class ReturnNull { + public String foo() { + return null; + } + } +} diff --git a/compiler/testData/ir/irText/classes/delegatedImplementation.txt b/compiler/testData/ir/irText/classes/delegatedImplementation.txt index 54da50fa0d5..4b1b3f5791e 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementation.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementation.txt @@ -209,7 +209,7 @@ FILE fqName: fileName:/delegatedImplementation.kt $this: VALUE_PARAMETER name: type:.Test1 BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun bar (): kotlin.Int declared in .Test1' - CALL 'public abstract fun bar (): kotlin.Int declared in .IBase' type=kotlin.Int origin=null + CALL 'public open fun bar (): kotlin.Int declared in .BaseImpl' type=kotlin.Int origin=null $this: GET_FIELD 'FIELD DELEGATE name:Test1$IBase$delegate type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null receiver: GET_VAR ': .Test1 declared in .Test1.bar' type=.Test1 origin=null FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.Test1, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit @@ -219,7 +219,7 @@ FILE fqName: fileName:/delegatedImplementation.kt VALUE_PARAMETER name:x index:0 type:kotlin.Int VALUE_PARAMETER name:s index:1 type:kotlin.String BLOCK_BODY - CALL 'public abstract fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + CALL 'public open fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in .BaseImpl' type=kotlin.Unit origin=null $this: GET_FIELD 'FIELD DELEGATE name:Test1$IBase$delegate type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null receiver: GET_VAR ': .Test1 declared in .Test1.foo' type=.Test1 origin=null x: GET_VAR 'x: kotlin.Int declared in .Test1.foo' type=kotlin.Int origin=null @@ -230,7 +230,7 @@ FILE fqName: fileName:/delegatedImplementation.kt $this: VALUE_PARAMETER name: type:.Test1 $receiver: VALUE_PARAMETER name: type:kotlin.String BLOCK_BODY - CALL 'public abstract fun qux (): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + CALL 'public open fun qux (): kotlin.Unit declared in .BaseImpl' type=kotlin.Unit origin=null $this: GET_FIELD 'FIELD DELEGATE name:Test1$IBase$delegate type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null receiver: GET_VAR ': .Test1 declared in .Test1.qux' type=.Test1 origin=null $receiver: GET_VAR ': kotlin.String declared in .Test1.qux' type=kotlin.String origin=null @@ -262,7 +262,7 @@ FILE fqName: fileName:/delegatedImplementation.kt $this: VALUE_PARAMETER name: type:.Test2 BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun bar (): kotlin.Int declared in .Test2' - CALL 'public abstract fun bar (): kotlin.Int declared in .IBase' type=kotlin.Int origin=null + CALL 'public open fun bar (): kotlin.Int declared in .BaseImpl' type=kotlin.Int origin=null $this: GET_FIELD 'FIELD DELEGATE name:Test2$IBase$delegate type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null receiver: GET_VAR ': .Test2 declared in .Test2.bar' type=.Test2 origin=null FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.Test2, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit @@ -272,7 +272,7 @@ FILE fqName: fileName:/delegatedImplementation.kt VALUE_PARAMETER name:x index:0 type:kotlin.Int VALUE_PARAMETER name:s index:1 type:kotlin.String BLOCK_BODY - CALL 'public abstract fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + CALL 'public open fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in .BaseImpl' type=kotlin.Unit origin=null $this: GET_FIELD 'FIELD DELEGATE name:Test2$IBase$delegate type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null receiver: GET_VAR ': .Test2 declared in .Test2.foo' type=.Test2 origin=null x: GET_VAR 'x: kotlin.Int declared in .Test2.foo' type=kotlin.Int origin=null @@ -283,7 +283,7 @@ FILE fqName: fileName:/delegatedImplementation.kt $this: VALUE_PARAMETER name: type:.Test2 $receiver: VALUE_PARAMETER name: type:kotlin.String BLOCK_BODY - CALL 'public abstract fun qux (): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + CALL 'public open fun qux (): kotlin.Unit declared in .BaseImpl' type=kotlin.Unit origin=null $this: GET_FIELD 'FIELD DELEGATE name:Test2$IBase$delegate type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null receiver: GET_VAR ': .Test2 declared in .Test2.qux' type=.Test2 origin=null $receiver: GET_VAR ': kotlin.String declared in .Test2.qux' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.txt b/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.txt index 42e1844d749..d8d93e215f1 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.txt @@ -61,7 +61,7 @@ FILE fqName: fileName:/delegatedImplementationWithExplicitOverride.kt public abstract fun foo (): kotlin.Unit declared in .IFooBar $this: VALUE_PARAMETER name: type:.C BLOCK_BODY - CALL 'public abstract fun foo (): kotlin.Unit declared in .IFooBar' type=kotlin.Unit origin=null + CALL 'public open fun foo (): kotlin.Unit declared in .FooBarImpl' type=kotlin.Unit origin=null $this: GET_FIELD 'FIELD DELEGATE name:C$IFooBar$delegate type:.FooBarImpl visibility:private [final]' type=.FooBarImpl origin=null receiver: GET_VAR ': .C declared in .C.foo' type=.C origin=null FUN name:bar visibility:public modality:OPEN <> ($this:.C) returnType:kotlin.Unit diff --git a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.txt b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.txt new file mode 100644 index 00000000000..b8d342dbc0a --- /dev/null +++ b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.txt @@ -0,0 +1,229 @@ +FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt + CLASS INTERFACE name:IFoo modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IFoo + FUN name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.IFoo + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:K1 modality:FINAL visibility:public superTypes:[.JFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K1 + CONSTRUCTOR visibility:public <> () returnType:.K1 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .JFoo' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K1 modality:FINAL visibility:public superTypes:[.JFoo]' + FUN FAKE_OVERRIDE name:foo visibility:public modality:OPEN <> ($this:.JFoo) returnType:kotlin.String [fake_override,operator] + overridden: + public open fun foo (): kotlin.String [operator] declared in .JFoo + $this: VALUE_PARAMETER name: type:.JFoo + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:K2 modality:FINAL visibility:public superTypes:[.JFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K2 + CONSTRUCTOR visibility:public <> () returnType:.K2 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .JFoo' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K2 modality:FINAL visibility:public superTypes:[.JFoo]' + FUN name:foo visibility:public modality:FINAL <> ($this:.K2) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.K2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.String declared in .K2' + CALL 'public open fun foo (): kotlin.String [operator] declared in .JFoo' type=kotlin.String origin=null + $this: ERROR_CALL 'Unresolved reference: super' type=.JFoo + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:K3 modality:FINAL visibility:public superTypes:[.JUnrelatedFoo; .IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K3 + CONSTRUCTOR visibility:public <> () returnType:.K3 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .JUnrelatedFoo' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K3 modality:FINAL visibility:public superTypes:[.JUnrelatedFoo; .IFoo]' + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String [fake_override] + overridden: + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.IFoo + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:K4 modality:FINAL visibility:public superTypes:[.JUnrelatedFoo; .IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K4 + CONSTRUCTOR visibility:public <> () returnType:.K4 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .JUnrelatedFoo' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K4 modality:FINAL visibility:public superTypes:[.JUnrelatedFoo; .IFoo]' + FUN name:foo visibility:public modality:FINAL <> ($this:.K4) returnType:kotlin.String? + $this: VALUE_PARAMETER name: type:.K4 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.String? declared in .K4' + CALL 'public open fun foo (): kotlin.String? [operator] declared in .JUnrelatedFoo' type=kotlin.String? origin=null + $this: ERROR_CALL 'Unresolved reference: super' type=.JUnrelatedFoo + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:TestJFoo modality:FINAL visibility:public superTypes:[.IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestJFoo + CONSTRUCTOR visibility:public <> () returnType:.TestJFoo [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestJFoo modality:FINAL visibility:public superTypes:[.IFoo]' + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String [fake_override] + overridden: + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.IFoo + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:TestK1 modality:FINAL visibility:public superTypes:[.IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestK1 + CONSTRUCTOR visibility:public <> () returnType:.TestK1 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK1 modality:FINAL visibility:public superTypes:[.IFoo]' + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String [fake_override] + overridden: + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.IFoo + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:TestK2 modality:FINAL visibility:public superTypes:[.IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestK2 + CONSTRUCTOR visibility:public <> () returnType:.TestK2 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK2 modality:FINAL visibility:public superTypes:[.IFoo]' + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String [fake_override] + overridden: + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.IFoo + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:TestK3 modality:FINAL visibility:public superTypes:[.IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestK3 + CONSTRUCTOR visibility:public <> () returnType:.TestK3 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK3 modality:FINAL visibility:public superTypes:[.IFoo]' + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String [fake_override] + overridden: + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.IFoo + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:TestK4 modality:FINAL visibility:public superTypes:[.IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestK4 + CONSTRUCTOR visibility:public <> () returnType:.TestK4 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK4 modality:FINAL visibility:public superTypes:[.IFoo]' + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String [fake_override] + overridden: + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.IFoo + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.kt b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.kt new file mode 100644 index 00000000000..6a3105fd7c3 --- /dev/null +++ b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.kt @@ -0,0 +1,47 @@ +// FILE: implicitNotNullOnDelegatedImplementation.kt +interface IFoo { + fun foo(): String +} + +class K1 : JFoo() + +class K2 : JFoo() { + override fun foo() = super.foo() +} + +class K3 : JUnrelatedFoo(), IFoo + +class K4 : JUnrelatedFoo(), IFoo { + override fun foo() = super.foo() +} + +class TestJFoo : IFoo by JFoo() { + // nullability assertion in 'foo()' +} + +class TestK1 : IFoo by K1() { + // nullability assertion in 'foo()' +} + +class TestK2 : IFoo by K2() { + // no nullability assertion in 'foo()' +} + +class TestK3 : IFoo by K3() { + // no nullability assertion in 'foo()' +} + +class TestK4 : IFoo by K4() { + // nullability assertion in 'foo()' +} + + +// FILE: JFoo.java +public class JFoo implements IFoo { + public String foo() { return null; } +} + +// FILE: JUnrelatedFoo.java +public class JUnrelatedFoo { + public String foo() { return null; } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.txt b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.txt new file mode 100644 index 00000000000..f69e13973b2 --- /dev/null +++ b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.txt @@ -0,0 +1,285 @@ +FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt + CLASS INTERFACE name:IFoo modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IFoo + FUN name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.IFoo + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:K1 modality:FINAL visibility:public superTypes:[.JFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K1 + CONSTRUCTOR visibility:public <> () returnType:.K1 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .JFoo' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K1 modality:FINAL visibility:public superTypes:[.JFoo]' + 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 [fake_override,operator] declared in .JFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:foo visibility:public modality:OPEN <> ($this:.JFoo) returnType:kotlin.String [fake_override] + overridden: + public open fun foo (): kotlin.String declared in .JFoo + $this: VALUE_PARAMETER name: type:.JFoo + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .JFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .JFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:K2 modality:FINAL visibility:public superTypes:[.JFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K2 + CONSTRUCTOR visibility:public <> () returnType:.K2 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .JFoo' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K2 modality:FINAL visibility:public superTypes:[.JFoo]' + FUN name:foo visibility:public modality:OPEN <> ($this:.K2) returnType:kotlin.String + overridden: + public open fun foo (): kotlin.String declared in .JFoo + $this: VALUE_PARAMETER name: type:.K2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .K2' + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + CALL 'public open fun foo (): kotlin.String declared in .JFoo' superQualifier='CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:JFoo modality:OPEN visibility:public superTypes:[.IFoo]' type=kotlin.String origin=null + $this: GET_VAR ': .K2 declared in .K2.foo' type=.K2 origin=null + 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 [fake_override,operator] declared in .JFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .JFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .JFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:K3 modality:FINAL visibility:public superTypes:[.JUnrelatedFoo; .IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K3 + CONSTRUCTOR visibility:public <> () returnType:.K3 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .JUnrelatedFoo' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K3 modality:FINAL visibility:public superTypes:[.JUnrelatedFoo; .IFoo]' + 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 [fake_override,operator] declared in .JUnrelatedFoo + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:foo visibility:public modality:OPEN <> ($this:.IFoo) returnType:kotlin.String [fake_override] + overridden: + public open fun foo (): kotlin.String? declared in .JUnrelatedFoo + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.IFoo + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .JUnrelatedFoo + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .JUnrelatedFoo + public open fun toString (): kotlin.String [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:K4 modality:FINAL visibility:public superTypes:[.JUnrelatedFoo; .IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K4 + CONSTRUCTOR visibility:public <> () returnType:.K4 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .JUnrelatedFoo' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K4 modality:FINAL visibility:public superTypes:[.JUnrelatedFoo; .IFoo]' + FUN name:foo visibility:public modality:OPEN <> ($this:.K4) returnType:kotlin.String? + overridden: + public open fun foo (): kotlin.String? declared in .JUnrelatedFoo + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.K4 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String? declared in .K4' + CALL 'public open fun foo (): kotlin.String? declared in .JUnrelatedFoo' superQualifier='CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:JUnrelatedFoo modality:OPEN visibility:public superTypes:[kotlin.Any]' type=kotlin.String? origin=null + $this: GET_VAR ': .K4 declared in .K4.foo' type=.K4 origin=null + 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 [fake_override,operator] declared in .JUnrelatedFoo + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .JUnrelatedFoo + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .JUnrelatedFoo + public open fun toString (): kotlin.String [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:TestJFoo modality:FINAL visibility:public superTypes:[.IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestJFoo + CONSTRUCTOR visibility:public <> () returnType:.TestJFoo [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestJFoo modality:FINAL visibility:public superTypes:[.IFoo]' + FIELD DELEGATE name:TestJFoo$IFoo$delegate type:.JFoo visibility:private [final] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .JFoo' type=.JFoo origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestJFoo) returnType:kotlin.String + overridden: + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.TestJFoo + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestJFoo' + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + CALL 'public open fun foo (): kotlin.String declared in .JFoo' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:TestJFoo$IFoo$delegate type:.JFoo visibility:private [final]' type=.JFoo origin=null + receiver: GET_VAR ': .TestJFoo declared in .TestJFoo.foo' type=.TestJFoo origin=null + 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 [fake_override,operator] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:TestK1 modality:FINAL visibility:public superTypes:[.IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestK1 + CONSTRUCTOR visibility:public <> () returnType:.TestK1 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK1 modality:FINAL visibility:public superTypes:[.IFoo]' + FIELD DELEGATE name:TestK1$IFoo$delegate type:.K1 visibility:private [final] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K1' type=.K1 origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestK1) returnType:kotlin.String + overridden: + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.TestK1 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK1' + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + CALL 'public open fun foo (): kotlin.String [fake_override] declared in .K1' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:TestK1$IFoo$delegate type:.K1 visibility:private [final]' type=.K1 origin=null + receiver: GET_VAR ': .TestK1 declared in .TestK1.foo' type=.TestK1 origin=null + 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 [fake_override,operator] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:TestK2 modality:FINAL visibility:public superTypes:[.IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestK2 + CONSTRUCTOR visibility:public <> () returnType:.TestK2 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK2 modality:FINAL visibility:public superTypes:[.IFoo]' + FIELD DELEGATE name:TestK2$IFoo$delegate type:.K2 visibility:private [final] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K2' type=.K2 origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestK2) returnType:kotlin.String + overridden: + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.TestK2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK2' + CALL 'public open fun foo (): kotlin.String declared in .K2' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:TestK2$IFoo$delegate type:.K2 visibility:private [final]' type=.K2 origin=null + receiver: GET_VAR ': .TestK2 declared in .TestK2.foo' type=.TestK2 origin=null + 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 [fake_override,operator] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:TestK3 modality:FINAL visibility:public superTypes:[.IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestK3 + CONSTRUCTOR visibility:public <> () returnType:.TestK3 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK3 modality:FINAL visibility:public superTypes:[.IFoo]' + FIELD DELEGATE name:TestK3$IFoo$delegate type:.K3 visibility:private [final] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K3' type=.K3 origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestK3) returnType:kotlin.String + overridden: + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.TestK3 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK3' + CALL 'public open fun foo (): kotlin.String [fake_override] declared in .K3' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:TestK3$IFoo$delegate type:.K3 visibility:private [final]' type=.K3 origin=null + receiver: GET_VAR ': .TestK3 declared in .TestK3.foo' type=.TestK3 origin=null + 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 [fake_override,operator] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:TestK4 modality:FINAL visibility:public superTypes:[.IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestK4 + CONSTRUCTOR visibility:public <> () returnType:.TestK4 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK4 modality:FINAL visibility:public superTypes:[.IFoo]' + FIELD DELEGATE name:TestK4$IFoo$delegate type:.K4 visibility:private [final] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K4' type=.K4 origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestK4) returnType:kotlin.String + overridden: + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.TestK4 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK4' + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + CALL 'public open fun foo (): kotlin.String? declared in .K4' type=kotlin.String? origin=null + $this: GET_FIELD 'FIELD DELEGATE name:TestK4$IFoo$delegate type:.K4 visibility:private [final]' type=.K4 origin=null + receiver: GET_VAR ': .TestK4 declared in .TestK4.foo' type=.TestK4 origin=null + 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 [fake_override,operator] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 0084f07b08a..6167f27e06c 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -125,6 +125,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/classes/enumWithSecondaryCtor.kt"); } + @TestMetadata("implicitNotNullOnDelegatedImplementation.kt") + public void testImplicitNotNullOnDelegatedImplementation() throws Exception { + runTest("compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.kt"); + } + @TestMetadata("initBlock.kt") public void testInitBlock() throws Exception { runTest("compiler/testData/ir/irText/classes/initBlock.kt");