IR: fix "most specific" check in IrFakeOverrideBuilder
There were several problems with it: 1) `isMoreSpecific` should return true if a == b. Otherwise `isMoreSpecificThenAllOf` would never return true because it's always invoked with a collection that contains the candidate. K1 behaves similarly, `OverridingUtil.isMoreSpecific` returns true if a == b. So in fact, "more" should be understood as "not less" here. 2) `transitivelyMostSpecificMember` in `selectMostSpecificMember` was always equal to the first element, so `isMoreSpecific` was invoked with incorrect arguments. 3) At the end of `selectMostSpecificMember`, we selected the first candidate with the non-flexible return type, however only dynamic type was considered. We need to check `isFlexible` via type system instead. #KT-66120 Fixed
This commit is contained in:
committed by
Space Team
parent
a08df1821f
commit
77b3f415a5
Vendored
+4
-4
@@ -295,14 +295,14 @@ FILE fqName:<root> fileName:/1.kt
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.Java1'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:H modality:FINAL visibility:public superTypes:[<root>.Java1; <root>.Java2; <root>.Java3]'
|
||||
FUN FAKE_OVERRIDE name:bar visibility:public modality:OPEN <> ($this:<root>.Java3) returnType:@[EnhancedNullability] kotlin.String? [fake_override]
|
||||
FUN FAKE_OVERRIDE name:bar visibility:public modality:OPEN <> ($this:<root>.Java2) returnType:@[EnhancedNullability] kotlin.String [fake_override]
|
||||
annotations:
|
||||
Nullable(value = <null>)
|
||||
NotNull(value = <null>)
|
||||
overridden:
|
||||
public open fun bar (): @[FlexibleNullability] kotlin.String? declared in <root>.Java1
|
||||
public abstract fun bar (): @[EnhancedNullability] kotlin.String declared in <root>.Java2
|
||||
public abstract fun bar (): @[EnhancedNullability] kotlin.String? declared in <root>.Java3
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Java3
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Java2
|
||||
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 declared in <root>.Java1
|
||||
@@ -488,7 +488,7 @@ FILE fqName:<root> fileName:/1.kt
|
||||
receiver: GET_VAR 'h: <root>.H declared in <root>.test' type=<root>.H origin=null
|
||||
VAR name:k16 type:kotlin.String [val]
|
||||
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
CALL 'public open fun bar (): @[EnhancedNullability] kotlin.String? declared in <root>.H' type=@[EnhancedNullability] kotlin.String origin=null
|
||||
CALL 'public open fun bar (): @[EnhancedNullability] kotlin.String declared in <root>.H' type=@[EnhancedNullability] kotlin.String origin=null
|
||||
$this: GET_VAR 'h: <root>.H declared in <root>.test' type=<root>.H origin=null
|
||||
CALL 'public open fun foo (s: @[FlexibleNullability] kotlin.String?): kotlin.Unit declared in <root>.H' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR 'h: <root>.H declared in <root>.test' type=<root>.H origin=null
|
||||
|
||||
Reference in New Issue
Block a user