From 429bf78afafcad216f8ff2a5932ee688c6633197 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 3 Dec 2019 11:47:21 +0300 Subject: [PATCH] Add 'Collection#contains' as a special case to psi2ir tests --- .../implicitNotNullOnPlatformType.fir.txt | 57 ++++++++++++++++ .../types/implicitNotNullOnPlatformType.kt | 13 ++++ .../types/implicitNotNullOnPlatformType.txt | 65 +++++++++++++++++++ 3 files changed, 135 insertions(+) diff --git a/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.fir.txt b/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.fir.txt index 65d510262fb..d55cf0898d6 100644 --- a/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.fir.txt +++ b/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.fir.txt @@ -2,9 +2,66 @@ FILE fqName: fileName:/implicitNotNullOnPlatformType.kt FUN name:f visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.Unit VALUE_PARAMETER name:s index:0 type:kotlin.String BLOCK_BODY + CLASS CLASS name:MySet modality:FINAL visibility:public superTypes:[kotlin.collections.Set] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MySet + CONSTRUCTOR visibility:public <> () returnType:.MySet [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MySet modality:FINAL visibility:public superTypes:[kotlin.collections.Set]' + PROPERTY name:size visibility:public modality:FINAL [val] + FUN name: visibility:public modality:FINAL <> ($this:.MySet) returnType:kotlin.Int + correspondingProperty: PROPERTY name:size visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.MySet + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .MySet' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + FUN name:contains visibility:public modality:FINAL <> ($this:.MySet, element:kotlin.String) returnType:kotlin.Boolean + $this: VALUE_PARAMETER name: type:.MySet + VALUE_PARAMETER name:element index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun contains (element: kotlin.String): kotlin.Boolean declared in .MySet' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + FUN name:containsAll visibility:public modality:FINAL <> ($this:.MySet, elements:kotlin.collections.Collection) returnType:kotlin.Boolean + $this: VALUE_PARAMETER name: type:.MySet + VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in .MySet' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + FUN name:isEmpty visibility:public modality:FINAL <> ($this:.MySet) returnType:kotlin.Boolean + $this: VALUE_PARAMETER name: type:.MySet + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun isEmpty (): kotlin.Boolean declared in .MySet' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + FUN name:iterator visibility:public modality:FINAL <> ($this:.MySet) returnType:kotlin.collections.Iterator + $this: VALUE_PARAMETER name: type:.MySet + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun iterator (): kotlin.collections.Iterator declared in .MySet' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing 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 [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 FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun f (s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null s: CALL 'public open fun s (): kotlin.String? [operator] declared in .J' type=kotlin.String? origin=null CALL 'public final fun f (s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null s: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:kotlin.String? visibility:public [static]' type=kotlin.String? origin=GET_PROPERTY + FUN name:testContains visibility:public modality:FINAL <> (m:.MySet) returnType:kotlin.Unit + VALUE_PARAMETER name:m index:0 type:.MySet + BLOCK_BODY + CALL 'public final fun contains (element: kotlin.String): kotlin.Boolean declared in .MySet' type=kotlin.Boolean origin=null + $this: GET_VAR 'm: .MySet declared in .testContains' type=.MySet origin=null + element: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:kotlin.String? visibility:public [static]' type=kotlin.String? origin=GET_PROPERTY + CALL 'public final fun contains (element: kotlin.String): kotlin.Boolean declared in .MySet' type=kotlin.Boolean origin=null + $this: GET_VAR 'm: .MySet declared in .testContains' type=.MySet origin=null + element: CONST String type=kotlin.String value="abc" diff --git a/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.kt b/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.kt index 82593a33b1b..275653dec15 100644 --- a/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.kt +++ b/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.kt @@ -1,11 +1,24 @@ // FILE: implicitNotNullOnPlatformType.kt fun f(s: String) {} +class MySet : Set { + override val size: Int get() = TODO() + override fun contains(element: String): Boolean = TODO() + override fun containsAll(elements: Collection): Boolean = TODO() + override fun isEmpty(): Boolean = TODO() + override fun iterator(): Iterator = TODO() +} + fun test() { f(J.s()) f(J.STRING) } +fun testContains(m: MySet) { + m.contains(J.STRING) + m.contains("abc") +} + // FILE: J.java public class J { public static String STRING = s(); diff --git a/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.txt b/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.txt index 5c6560262d5..ed26848572c 100644 --- a/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.txt +++ b/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.txt @@ -2,6 +2,59 @@ FILE fqName: fileName:/implicitNotNullOnPlatformType.kt FUN name:f visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.Unit VALUE_PARAMETER name:s index:0 type:kotlin.String BLOCK_BODY + CLASS CLASS name:MySet modality:FINAL visibility:public superTypes:[kotlin.collections.Set] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MySet + CONSTRUCTOR visibility:public <> () returnType:.MySet [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MySet modality:FINAL visibility:public superTypes:[kotlin.collections.Set]' + PROPERTY name:size visibility:public modality:OPEN [val] + FUN name: visibility:public modality:OPEN <> ($this:.MySet) returnType:kotlin.Int + correspondingProperty: PROPERTY name:size visibility:public modality:OPEN [val] + overridden: + public abstract fun (): kotlin.Int declared in kotlin.collections.Set + $this: VALUE_PARAMETER name: type:.MySet + BLOCK_BODY + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + FUN name:contains visibility:public modality:OPEN <> ($this:.MySet, element:kotlin.String) returnType:kotlin.Boolean [operator] + overridden: + public abstract fun contains (element: E of kotlin.collections.Set): kotlin.Boolean [operator] declared in kotlin.collections.Set + $this: VALUE_PARAMETER name: type:.MySet + VALUE_PARAMETER name:element index:0 type:kotlin.String + BLOCK_BODY + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + FUN name:containsAll visibility:public modality:OPEN <> ($this:.MySet, elements:kotlin.collections.Collection) returnType:kotlin.Boolean + overridden: + public abstract fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.Set + $this: VALUE_PARAMETER name: type:.MySet + VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection + BLOCK_BODY + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + FUN name:isEmpty visibility:public modality:OPEN <> ($this:.MySet) returnType:kotlin.Boolean + overridden: + public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.Set + $this: VALUE_PARAMETER name: type:.MySet + BLOCK_BODY + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + FUN name:iterator visibility:public modality:OPEN <> ($this:.MySet) returnType:kotlin.collections.Iterator [operator] + overridden: + public abstract fun iterator (): kotlin.collections.Iterator [operator] declared in kotlin.collections.Set + $this: VALUE_PARAMETER name: type:.MySet + BLOCK_BODY + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing 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 kotlin.collections.Set + $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 kotlin.collections.Set + $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 kotlin.collections.Set + $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun f (s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null @@ -10,3 +63,15 @@ FILE fqName: fileName:/implicitNotNullOnPlatformType.kt CALL 'public final fun f (s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null s: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:kotlin.String? visibility:public [static]' type=kotlin.String? origin=GET_PROPERTY + FUN name:testContains visibility:public modality:FINAL <> (m:.MySet) returnType:kotlin.Unit + VALUE_PARAMETER name:m index:0 type:.MySet + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public open fun contains (element: kotlin.String): kotlin.Boolean [operator] declared in .MySet' type=kotlin.Boolean origin=null + $this: GET_VAR 'm: .MySet declared in .testContains' type=.MySet origin=null + element: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:kotlin.String? visibility:public [static]' type=kotlin.String? origin=GET_PROPERTY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public open fun contains (element: kotlin.String): kotlin.Boolean [operator] declared in .MySet' type=kotlin.Boolean origin=null + $this: GET_VAR 'm: .MySet declared in .testContains' type=.MySet origin=null + element: CONST String type=kotlin.String value="abc"