[FIR] Fix enhancement of FlexibleNullability and EnhancedNullability
- Add utilities to add new attribute to ConeAttributes
- Get rid of FlexibleNullability attribute (it can be easily inferred
for any flexible type at any moment)
- Fix determining of EnhancedNullability attribute
This commit is contained in:
+5
-4
@@ -9,11 +9,11 @@ class Test : J {
|
||||
<this>.#<$$delegate_0>.takeNotNull(x = x)
|
||||
}
|
||||
|
||||
override fun takeNullable(x: @FlexibleNullability String?) {
|
||||
override fun takeNullable(x: @EnhancedNullability String?) {
|
||||
<this>.#<$$delegate_0>.takeNullable(x = x)
|
||||
}
|
||||
|
||||
override fun takeFlexible(x: String?) {
|
||||
override fun takeFlexible(x: @FlexibleNullability String?) {
|
||||
<this>.#<$$delegate_0>.takeFlexible(x = x)
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ class Test : J {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
override fun returnNullable(): @FlexibleNullability String? {
|
||||
override fun returnNullable(): @EnhancedNullability String? {
|
||||
return <this>.#<$$delegate_0>.returnNullable()
|
||||
}
|
||||
|
||||
override fun returnsFlexible(): String? {
|
||||
override fun returnsFlexible(): @FlexibleNullability String? {
|
||||
return <this>.#<$$delegate_0>.returnsFlexible()
|
||||
}
|
||||
|
||||
@@ -37,3 +37,4 @@ class Test : J {
|
||||
private get
|
||||
|
||||
}
|
||||
|
||||
|
||||
+22
-22
@@ -16,26 +16,26 @@ FILE fqName:<root> fileName:/delegatedImplementationOfJavaInterface.kt
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.takeNotNull' type=<root>.Test origin=null
|
||||
x: GET_VAR 'x: @[EnhancedNullability] kotlin.String declared in <root>.Test.takeNotNull' type=@[EnhancedNullability] kotlin.String origin=null
|
||||
FUN DELEGATED_MEMBER name:takeNullable visibility:public modality:OPEN <> ($this:<root>.Test, x:@[FlexibleNullability] kotlin.String?) returnType:kotlin.Unit
|
||||
FUN DELEGATED_MEMBER name:takeNullable visibility:public modality:OPEN <> ($this:<root>.Test, x:@[EnhancedNullability] kotlin.String?) returnType:kotlin.Unit
|
||||
overridden:
|
||||
public abstract fun takeNullable (x: @[FlexibleNullability] kotlin.String?): kotlin.Unit declared in <root>.J
|
||||
public abstract fun takeNullable (x: @[EnhancedNullability] kotlin.String?): kotlin.Unit declared in <root>.J
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Test
|
||||
VALUE_PARAMETER name:x index:0 type:@[EnhancedNullability] kotlin.String?
|
||||
BLOCK_BODY
|
||||
CALL 'public abstract fun takeNullable (x: @[EnhancedNullability] kotlin.String?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.takeNullable' type=<root>.Test origin=null
|
||||
x: GET_VAR 'x: @[EnhancedNullability] kotlin.String? declared in <root>.Test.takeNullable' type=@[EnhancedNullability] kotlin.String? origin=null
|
||||
FUN DELEGATED_MEMBER name:takeFlexible visibility:public modality:OPEN <> ($this:<root>.Test, x:@[FlexibleNullability] kotlin.String?) returnType:kotlin.Unit
|
||||
overridden:
|
||||
public abstract fun takeFlexible (x: @[FlexibleNullability] kotlin.String?): kotlin.Unit declared in <root>.J
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Test
|
||||
VALUE_PARAMETER name:x index:0 type:@[FlexibleNullability] kotlin.String?
|
||||
BLOCK_BODY
|
||||
CALL 'public abstract fun takeNullable (x: @[FlexibleNullability] kotlin.String?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.takeNullable' type=<root>.Test origin=null
|
||||
x: GET_VAR 'x: @[FlexibleNullability] kotlin.String? declared in <root>.Test.takeNullable' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
FUN DELEGATED_MEMBER name:takeFlexible visibility:public modality:OPEN <> ($this:<root>.Test, x:kotlin.String?) returnType:kotlin.Unit
|
||||
overridden:
|
||||
public abstract fun takeFlexible (x: kotlin.String?): kotlin.Unit declared in <root>.J
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Test
|
||||
VALUE_PARAMETER name:x index:0 type:kotlin.String?
|
||||
BLOCK_BODY
|
||||
CALL 'public abstract fun takeFlexible (x: kotlin.String?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||
CALL 'public abstract fun takeFlexible (x: @[FlexibleNullability] kotlin.String?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.takeFlexible' type=<root>.Test origin=null
|
||||
x: GET_VAR 'x: kotlin.String? declared in <root>.Test.takeFlexible' type=kotlin.String? origin=null
|
||||
x: GET_VAR 'x: @[FlexibleNullability] kotlin.String? declared in <root>.Test.takeFlexible' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
FUN DELEGATED_MEMBER name:returnNotNull visibility:public modality:OPEN <> ($this:<root>.Test) returnType:@[EnhancedNullability] kotlin.String
|
||||
annotations:
|
||||
NotNull(value = <null>)
|
||||
@@ -47,24 +47,24 @@ FILE fqName:<root> fileName:/delegatedImplementationOfJavaInterface.kt
|
||||
CALL 'public abstract fun returnNotNull (): @[EnhancedNullability] kotlin.String declared in <root>.J' type=@[EnhancedNullability] kotlin.String origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.returnNotNull' type=<root>.Test origin=null
|
||||
FUN DELEGATED_MEMBER name:returnNullable visibility:public modality:OPEN <> ($this:<root>.Test) returnType:@[FlexibleNullability] kotlin.String?
|
||||
FUN DELEGATED_MEMBER name:returnNullable visibility:public modality:OPEN <> ($this:<root>.Test) returnType:@[EnhancedNullability] kotlin.String?
|
||||
annotations:
|
||||
Nullable(value = <null>)
|
||||
overridden:
|
||||
public abstract fun returnNullable (): @[FlexibleNullability] kotlin.String? declared in <root>.J
|
||||
public abstract fun returnNullable (): @[EnhancedNullability] kotlin.String? declared in <root>.J
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Test
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun returnNullable (): @[FlexibleNullability] kotlin.String? declared in <root>.Test'
|
||||
CALL 'public abstract fun returnNullable (): @[FlexibleNullability] kotlin.String? declared in <root>.J' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
RETURN type=kotlin.Nothing from='public open fun returnNullable (): @[EnhancedNullability] kotlin.String? declared in <root>.Test'
|
||||
CALL 'public abstract fun returnNullable (): @[EnhancedNullability] kotlin.String? declared in <root>.J' type=@[EnhancedNullability] kotlin.String? origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.returnNullable' type=<root>.Test origin=null
|
||||
FUN DELEGATED_MEMBER name:returnsFlexible visibility:public modality:OPEN <> ($this:<root>.Test) returnType:kotlin.String?
|
||||
FUN DELEGATED_MEMBER name:returnsFlexible visibility:public modality:OPEN <> ($this:<root>.Test) returnType:@[FlexibleNullability] kotlin.String?
|
||||
overridden:
|
||||
public abstract fun returnsFlexible (): kotlin.String? declared in <root>.J
|
||||
public abstract fun returnsFlexible (): @[FlexibleNullability] kotlin.String? declared in <root>.J
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Test
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun returnsFlexible (): kotlin.String? declared in <root>.Test'
|
||||
CALL 'public abstract fun returnsFlexible (): kotlin.String? declared in <root>.J' type=kotlin.String? origin=null
|
||||
RETURN type=kotlin.Nothing from='public open fun returnsFlexible (): @[FlexibleNullability] kotlin.String? declared in <root>.Test'
|
||||
CALL 'public abstract fun returnsFlexible (): @[FlexibleNullability] kotlin.String? declared in <root>.J' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.returnsFlexible' type=<root>.Test origin=null
|
||||
FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]
|
||||
|
||||
+4
-3
@@ -19,8 +19,8 @@ class K2 : JFoo {
|
||||
|
||||
}
|
||||
|
||||
override fun foo(): @FlexibleNullability String {
|
||||
return super.foo()
|
||||
override fun foo(): String {
|
||||
return super.foo() /*!! String */
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,7 +41,7 @@ class K4 : JUnrelatedFoo, IFoo {
|
||||
|
||||
}
|
||||
|
||||
override fun foo(): String? {
|
||||
override fun foo(): @FlexibleNullability String? {
|
||||
return super.foo()
|
||||
}
|
||||
|
||||
@@ -121,3 +121,4 @@ class TestK4 : IFoo {
|
||||
local /* final field */ val <$$delegate_0>: IFoo = K4()
|
||||
|
||||
}
|
||||
|
||||
|
||||
+13
-12
@@ -22,9 +22,9 @@ FILE fqName:<root> fileName:/implicitNotNullOnDelegatedImplementation.kt
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.JFoo'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K1 modality:FINAL visibility:public superTypes:[<root>.JFoo]'
|
||||
FUN FAKE_OVERRIDE name:foo visibility:public modality:OPEN <> ($this:<root>.JFoo) returnType:@[FlexibleNullability] kotlin.String [fake_override]
|
||||
FUN FAKE_OVERRIDE name:foo visibility:public modality:OPEN <> ($this:<root>.JFoo) returnType:@[EnhancedNullability] kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun foo (): @[FlexibleNullability] kotlin.String declared in <root>.JFoo
|
||||
public open fun foo (): @[EnhancedNullability] kotlin.String declared in <root>.JFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.JFoo
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
@@ -45,14 +45,15 @@ FILE fqName:<root> fileName:/implicitNotNullOnDelegatedImplementation.kt
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.JFoo'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K2 modality:FINAL visibility:public superTypes:[<root>.JFoo]'
|
||||
FUN name:foo visibility:public modality:FINAL <> ($this:<root>.K2) returnType:@[FlexibleNullability] kotlin.String
|
||||
FUN name:foo visibility:public modality:FINAL <> ($this:<root>.K2) returnType:kotlin.String
|
||||
overridden:
|
||||
public open fun foo (): @[FlexibleNullability] kotlin.String declared in <root>.JFoo
|
||||
public open fun foo (): @[EnhancedNullability] kotlin.String declared in <root>.JFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.K2
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun foo (): @[FlexibleNullability] kotlin.String declared in <root>.K2'
|
||||
CALL 'public open fun foo (): @[FlexibleNullability] kotlin.String declared in <root>.JFoo' superQualifier='CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:JFoo modality:OPEN visibility:public superTypes:[kotlin.Any; <root>.IFoo]' type=@[FlexibleNullability] kotlin.String origin=null
|
||||
$this: GET_VAR '<this>: <root>.K2 declared in <root>.K2.foo' type=<root>.K2 origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.String declared in <root>.K2'
|
||||
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
CALL 'public open fun foo (): @[EnhancedNullability] kotlin.String declared in <root>.JFoo' superQualifier='CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:JFoo modality:OPEN visibility:public superTypes:[kotlin.Any; <root>.IFoo]' type=@[EnhancedNullability] kotlin.String origin=null
|
||||
$this: GET_VAR '<this>: <root>.K2 declared in <root>.K2.foo' type=<root>.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 <root>.JFoo
|
||||
@@ -74,7 +75,7 @@ FILE fqName:<root> fileName:/implicitNotNullOnDelegatedImplementation.kt
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K3 modality:FINAL visibility:public superTypes:[<root>.JUnrelatedFoo; <root>.IFoo]'
|
||||
FUN FAKE_OVERRIDE name:foo visibility:public modality:OPEN <> ($this:<root>.IFoo) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun foo (): kotlin.String? declared in <root>.JUnrelatedFoo
|
||||
public open fun foo (): @[FlexibleNullability] kotlin.String? declared in <root>.JUnrelatedFoo
|
||||
public abstract fun foo (): kotlin.String declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.IFoo
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
@@ -99,14 +100,14 @@ FILE fqName:<root> fileName:/implicitNotNullOnDelegatedImplementation.kt
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.JUnrelatedFoo'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K4 modality:FINAL visibility:public superTypes:[<root>.JUnrelatedFoo; <root>.IFoo]'
|
||||
FUN name:foo visibility:public modality:FINAL <> ($this:<root>.K4) returnType:kotlin.String?
|
||||
FUN name:foo visibility:public modality:FINAL <> ($this:<root>.K4) returnType:@[FlexibleNullability] kotlin.String?
|
||||
overridden:
|
||||
public open fun foo (): kotlin.String? declared in <root>.JUnrelatedFoo
|
||||
public open fun foo (): @[FlexibleNullability] kotlin.String? declared in <root>.JUnrelatedFoo
|
||||
public abstract fun foo (): kotlin.String declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.K4
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.String? declared in <root>.K4'
|
||||
CALL 'public open fun foo (): kotlin.String? declared in <root>.JUnrelatedFoo' superQualifier='CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:JUnrelatedFoo modality:OPEN visibility:public superTypes:[kotlin.Any]' type=kotlin.String? origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun foo (): @[FlexibleNullability] kotlin.String? declared in <root>.K4'
|
||||
CALL 'public open fun foo (): @[FlexibleNullability] kotlin.String? declared in <root>.JUnrelatedFoo' superQualifier='CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:JUnrelatedFoo modality:OPEN visibility:public superTypes:[kotlin.Any]' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
$this: GET_VAR '<this>: <root>.K4 declared in <root>.K4.foo' type=<root>.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:
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ FILE fqName:<root> fileName:/kt43217.kt
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.DoubleExpression]'
|
||||
FUN name:get visibility:public modality:FINAL <> ($this:<root>.A.b.<no name provided>) returnType:kotlin.Double [operator]
|
||||
overridden:
|
||||
public abstract fun get (): @[FlexibleNullability] kotlin.Double [fake_override,operator] declared in <root>.DoubleExpression
|
||||
public abstract fun get (): kotlin.Double [fake_override,operator] declared in <root>.DoubleExpression
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A.b.<no name provided>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun get (): kotlin.Double [operator] declared in <root>.A.b.<no name provided>'
|
||||
@@ -72,7 +72,7 @@ FILE fqName:<root> fileName:/kt43217.kt
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.DoubleExpression]'
|
||||
FUN name:get visibility:public modality:FINAL <> ($this:<root>.C) returnType:kotlin.Double [operator]
|
||||
overridden:
|
||||
public abstract fun get (): @[FlexibleNullability] kotlin.Double [fake_override,operator] declared in <root>.DoubleExpression
|
||||
public abstract fun get (): kotlin.Double [fake_override,operator] declared in <root>.DoubleExpression
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun get (): kotlin.Double [operator] declared in <root>.C'
|
||||
|
||||
Reference in New Issue
Block a user