diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.kt deleted file mode 100644 index 6d05a605501..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.kt +++ /dev/null @@ -1,18 +0,0 @@ -// FILE: module-info.java -// INCLUDE_JAVA_AS_BINARY -import org.jspecify.nullness.NullMarked; - -@NullMarked -module sandbox { - requires java9_annotations; -} - -// FILE: Test.java -public class Test { - void foo(Integer x) {} -} - -// FILE: main.kt -fun main(x: Test) { - x.foo(1) -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.txt deleted file mode 100644 index fdf763e20ed..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.txt +++ /dev/null @@ -1,11 +0,0 @@ -package - -public fun main(/*0*/ x: Test): kotlin.Unit - -public open class Test { - public constructor Test() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public/*package*/ open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/basic.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/basic.kt new file mode 100644 index 00000000000..b6c311fe27f --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/basic.kt @@ -0,0 +1,25 @@ +// ALLOW_KOTLIN_PACKAGE +// JSPECIFY_STATE: strict + +// FILE: sandbox/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module sandbox { + requires java9_annotations; + exports test; +} + +// FILE: sandbox/test/Test.java +package test; + +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +import test.Test + +fun main(x: Test) { + x.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/basic.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/basic.txt new file mode 100644 index 00000000000..2c0728284ce --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/basic.txt @@ -0,0 +1,14 @@ +package + +public fun main(/*0*/ x: test.Test): kotlin.Unit + +package test { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithClassDefaultAnnotation.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithClassDefaultAnnotation.kt new file mode 100644 index 00000000000..2047f22629a --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithClassDefaultAnnotation.kt @@ -0,0 +1,28 @@ +// ALLOW_KOTLIN_PACKAGE +// JSPECIFY_STATE: strict + +// FILE: sandbox/test/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module sandbox { + requires java9_annotations; + exports test; +} + +// FILE: sandbox/test/Test.java +package test; + +import org.jspecify.nullness.NullMarked; + +@NullMarked +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +import test.Test + +fun main(x: Test) { + x.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithClassDefaultAnnotation.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithClassDefaultAnnotation.txt new file mode 100644 index 00000000000..c110723f194 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithClassDefaultAnnotation.txt @@ -0,0 +1,15 @@ +package + +public fun main(/*0*/ x: test.Test): kotlin.Unit + +package test { + + @org.jspecify.nullness.NullMarked public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithPackageDefaultAnnotation.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithPackageDefaultAnnotation.kt new file mode 100644 index 00000000000..ad4f72503c4 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithPackageDefaultAnnotation.kt @@ -0,0 +1,31 @@ +// ALLOW_KOTLIN_PACKAGE +// JSPECIFY_STATE: strict + +// FILE: sandbox/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module sandbox { + requires java9_annotations; + exports test; +} + +// FILE: sandbox/test/package-info.java +@NullMarked +package test; + +import org.jspecify.nullness.NullMarked; + +// FILE: sandbox/test/Test.java +package test; + +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +import test.Test + +fun main(x: Test) { + x.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithPackageDefaultAnnotation.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithPackageDefaultAnnotation.txt new file mode 100644 index 00000000000..224b6b6d5d7 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithPackageDefaultAnnotation.txt @@ -0,0 +1,15 @@ +package + +public fun main(/*0*/ x: test.Test): kotlin.Unit + +package test { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNoNullMarked.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNoNullMarked.kt new file mode 100644 index 00000000000..5dbdcd1cdc3 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNoNullMarked.kt @@ -0,0 +1,30 @@ +// ALLOW_KOTLIN_PACKAGE +// JSPECIFY_STATE: strict + +// MODULE: module1 +// FILE: module1/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module module1 { + requires java9_annotations; +} + +// MODULE: module2(module1) +// FILE: module2/module-info.java +module module2 { + requires module1; + exports test2; +} + +// FILE: module2/test2/Test.java +package test2; + +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +fun main(y: test2.Test) { + y.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNoNullMarked.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNoNullMarked.txt new file mode 100644 index 00000000000..cdba12947a6 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNoNullMarked.txt @@ -0,0 +1,20 @@ +// -- Module: -- +package + + +// -- Module: -- +package + +public fun main(/*0*/ y: test2.Test): kotlin.Unit + +package test2 { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNullMarked.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNullMarked.kt new file mode 100644 index 00000000000..753583013cc --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNullMarked.kt @@ -0,0 +1,30 @@ +// ALLOW_KOTLIN_PACKAGE +// JSPECIFY_STATE: strict + +// MODULE: module1 +// FILE: module1/module-info.java +module module1 { +} + +// MODULE: module2(module1) +// FILE: module2/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module module2 { + requires java9_annotations; + requires module1; + exports test2; +} + +// FILE: module2/test2/Test.java +package test2; + +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +fun main(y: test2.Test) { + y.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNullMarked.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNullMarked.txt new file mode 100644 index 00000000000..b5db4a1f4ad --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNullMarked.txt @@ -0,0 +1,20 @@ +// -- Module: -- +package + + +// -- Module: -- +package + +public fun main(/*0*/ y: test2.Test): kotlin.Unit + +package test2 { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt new file mode 100644 index 00000000000..be462fa9280 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt @@ -0,0 +1,44 @@ +// ALLOW_KOTLIN_PACKAGE +// JSPECIFY_STATE: strict + +// MODULE: sandbox +// FILE: sandbox/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module sandbox { + requires java9_annotations; + exports test; +} + +// FILE: sandbox/test/package-info.java +package test; + +// FILE: sandbox/test/Foo.java +package test; + +class Foo {} + +// MODULE: sandbox2 +// FILE: sandbox2/module-info.java +module sandbox2 { + requires java9_annotations; + exports test; +} + +// FILE: sandbox2/test/package-info.java +package test; + +// FILE: sandbox2/test/Test.java +package test; + +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +import test.Test + +fun main(x: Test) { + x.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.txt new file mode 100644 index 00000000000..8ecab7ee55c --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.txt @@ -0,0 +1,29 @@ +// -- Module: -- +package + +package test { + + public/*package*/ open class Foo { + public/*package*/ constructor Foo() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +// -- Module: -- +package + +public fun main(/*0*/ x: test.Test): kotlin.Unit + +package test { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dotNamedModule.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dotNamedModule.kt new file mode 100644 index 00000000000..120ade0ab3c --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dotNamedModule.kt @@ -0,0 +1,25 @@ +// ALLOW_KOTLIN_PACKAGE +// JSPECIFY_STATE: strict + +// FILE: my.sand.box/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +open module my.sand.box { + requires java9_annotations; + exports my.test; +} + +// FILE: my.sand.box/my/test/Test.java +package my.test; + +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +import my.test.Test + +fun main(x: Test) { + x.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dotNamedModule.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dotNamedModule.txt new file mode 100644 index 00000000000..f09de9d10a4 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dotNamedModule.txt @@ -0,0 +1,18 @@ +package + +public fun main(/*0*/ x: my.test.Test): kotlin.Unit + +package my { + + package my.test { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/inheritanceAcrossModules.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/inheritanceAcrossModules.kt new file mode 100644 index 00000000000..5273fe99b22 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/inheritanceAcrossModules.kt @@ -0,0 +1,45 @@ +// ALLOW_KOTLIN_PACKAGE +// JSPECIFY_STATE: strict + +// MODULE: module1 +// FILE: module1/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module module1 { + requires java9_annotations; + exports test1; +} + +// FILE: module1/test1/Test1.java +package test1; + +public class Test1 { + public void foo(Integer x) {} +} + +// MODULE: module2(module1) +// FILE: module2/module-info.java +module module2 { + requires module1; + exports test2; +} + +// FILE: module2/test2/Test2.java +package test2; + +import test1.Test1; + +public class Test2 extends Test1 { + public void foo2(Integer x) {} +} + +// FILE: main.kt +import test1.Test1 +import test2.Test2 + +fun main(x: Test1, y: Test2) { + x.foo(null) + y.foo(null) + y.foo2(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/inheritanceAcrossModules.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/inheritanceAcrossModules.txt new file mode 100644 index 00000000000..842e966d40c --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/inheritanceAcrossModules.txt @@ -0,0 +1,31 @@ +// -- Module: -- +package + +package test1 { + + public open class Test1 { + public constructor Test1() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +// -- Module: -- +package + +public fun main(/*0*/ x: test1.Test1, /*1*/ y: test2.Test2): kotlin.Unit + +package test2 { + + public open class Test2 : test1.Test1 { + public constructor Test2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: kotlin.Int): kotlin.Unit + public open fun foo2(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/nestedClasses.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/nestedClasses.kt new file mode 100644 index 00000000000..fe5137bfa8d --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/nestedClasses.kt @@ -0,0 +1,43 @@ +// ALLOW_KOTLIN_PACKAGE +// JSPECIFY_STATE: strict + +// FILE: sandbox/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module sandbox { + requires java9_annotations; + exports test; +} + +// FILE: sandbox/test/Test.java +package test; + +public class Test { + public static class Test2 { + public Integer foo(Integer x) { return 1; } + public static class Test4 { + public Integer foo(Integer x) { return 1; } + } + public class Test5 { + public Integer foo(Integer x) { return 1; } + } + } + public class Test3 { + public Integer foo(Integer x) { return 1; } + public class Test5 { + public Integer foo(Integer x) { return 1; } + } + } +} + +// FILE: main.kt +import test.Test + +fun main(x: Test) { + x.Test3().foo(null) + x.Test3().Test5().foo(null) + + Test.Test2().foo(null) + Test.Test2().Test5().foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/nestedClasses.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/nestedClasses.txt new file mode 100644 index 00000000000..644d975dbe5 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/nestedClasses.txt @@ -0,0 +1,54 @@ +package + +public fun main(/*0*/ x: test.Test): kotlin.Unit + +package test { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public open class Test2 { + public constructor Test2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public open class Test4 { + public constructor Test4() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open inner class Test5 { + public constructor Test5() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + + public open inner class Test3 { + public constructor Test3() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public open inner class Test5 { + public constructor Test5() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/overrideAtDeclarationLevel.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/overrideAtDeclarationLevel.kt new file mode 100644 index 00000000000..1903f33212c --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/overrideAtDeclarationLevel.kt @@ -0,0 +1,27 @@ +// ALLOW_KOTLIN_PACKAGE +// JSPECIFY_STATE: strict + +// FILE: sandbox/test/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module sandbox { + requires java9_annotations; + exports test; +} + +// FILE: sandbox/test/Test.java +package test; + +import org.jspecify.nullness.Nullable; + +public class Test { + public void foo(@Nullable Integer x) {} +} + +// FILE: main.kt +import test.Test + +fun main(x: Test) { + x.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/overrideAtDeclarationLevel.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/overrideAtDeclarationLevel.txt new file mode 100644 index 00000000000..bf64fb83fac --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/overrideAtDeclarationLevel.txt @@ -0,0 +1,15 @@ +package + +public fun main(/*0*/ x: test.Test): kotlin.Unit + +package test { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ @org.jspecify.nullness.Nullable x: @org.jspecify.nullness.Nullable kotlin.Int?): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/severalModulesDifferentPackages.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/severalModulesDifferentPackages.kt new file mode 100644 index 00000000000..5bead69eb46 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/severalModulesDifferentPackages.kt @@ -0,0 +1,39 @@ +// ALLOW_KOTLIN_PACKAGE +// JSPECIFY_STATE: strict + +// MODULE: module1 +// FILE: module1/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module module1 { + requires java9_annotations; + exports test1; +} + +// FILE: module1/test1/Test.java +package test1; + +public class Test { + public void foo(Integer x) {} +} + +// MODULE: module2(module1) +// FILE: module2/module-info.java +module module2 { + requires module1; + exports test2; +} + +// FILE: module2/test2/Test.java +package test2; + +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +fun main(x: test1.Test, y: test2.Test) { + x.foo(null) + y.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/severalModulesDifferentPackages.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/severalModulesDifferentPackages.txt new file mode 100644 index 00000000000..aae9804ec80 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/severalModulesDifferentPackages.txt @@ -0,0 +1,30 @@ +// -- Module: -- +package + +package test1 { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +// -- Module: -- +package + +public fun main(/*0*/ x: test1.Test, /*1*/ y: test2.Test): kotlin.Unit + +package test2 { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/basic.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/basic.kt new file mode 100644 index 00000000000..041204f8193 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/basic.kt @@ -0,0 +1,24 @@ +// ALLOW_KOTLIN_PACKAGE + +// FILE: sandbox/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module sandbox { + requires java9_annotations; + exports test; +} + +// FILE: sandbox/test/Test.java +package test; + +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +import test.Test + +fun main(x: Test) { + x.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/basic.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/basic.txt new file mode 100644 index 00000000000..faca03d295c --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/basic.txt @@ -0,0 +1,14 @@ +package + +public fun main(/*0*/ x: test.Test): kotlin.Unit + +package test { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.kt new file mode 100644 index 00000000000..a78a861ede3 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.kt @@ -0,0 +1,27 @@ +// ALLOW_KOTLIN_PACKAGE + +// FILE: sandbox/test/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module sandbox { + requires java9_annotations; + exports test; +} + +// FILE: sandbox/test/Test.java +package test; + +import org.jspecify.nullness.NullMarked; + +@NullMarked +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +import test.Test + +fun main(x: Test) { + x.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.txt new file mode 100644 index 00000000000..ed7d8b2b4da --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.txt @@ -0,0 +1,15 @@ +package + +public fun main(/*0*/ x: test.Test): kotlin.Unit + +package test { + + @org.jspecify.nullness.NullMarked public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.kt new file mode 100644 index 00000000000..da271a1ce0c --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.kt @@ -0,0 +1,30 @@ +// ALLOW_KOTLIN_PACKAGE + +// FILE: sandbox/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module sandbox { + requires java9_annotations; + exports test; +} + +// FILE: sandbox/test/package-info.java +@NullMarked +package test; + +import org.jspecify.nullness.NullMarked; + +// FILE: sandbox/test/Test.java +package test; + +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +import test.Test + +fun main(x: Test) { + x.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.txt new file mode 100644 index 00000000000..0f345e39f15 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.txt @@ -0,0 +1,15 @@ +package + +public fun main(/*0*/ x: test.Test): kotlin.Unit + +package test { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNoNullMarked.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNoNullMarked.kt new file mode 100644 index 00000000000..a639b59fdb6 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNoNullMarked.kt @@ -0,0 +1,29 @@ +// ALLOW_KOTLIN_PACKAGE + +// MODULE: module1 +// FILE: module1/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module module1 { + requires java9_annotations; +} + +// MODULE: module2(module1) +// FILE: module2/module-info.java +module module2 { + requires module1; + exports test2; +} + +// FILE: module2/test2/Test.java +package test2; + +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +fun main(y: test2.Test) { + y.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNoNullMarked.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNoNullMarked.txt new file mode 100644 index 00000000000..cdba12947a6 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNoNullMarked.txt @@ -0,0 +1,20 @@ +// -- Module: -- +package + + +// -- Module: -- +package + +public fun main(/*0*/ y: test2.Test): kotlin.Unit + +package test2 { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.kt new file mode 100644 index 00000000000..7bfc5195bf2 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.kt @@ -0,0 +1,29 @@ +// ALLOW_KOTLIN_PACKAGE + +// MODULE: module1 +// FILE: module1/module-info.java +module module1 { +} + +// MODULE: module2(module1) +// FILE: module2/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module module2 { + requires java9_annotations; + requires module1; + exports test2; +} + +// FILE: module2/test2/Test.java +package test2; + +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +fun main(y: test2.Test) { + y.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.txt new file mode 100644 index 00000000000..cdba12947a6 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.txt @@ -0,0 +1,20 @@ +// -- Module: -- +package + + +// -- Module: -- +package + +public fun main(/*0*/ y: test2.Test): kotlin.Unit + +package test2 { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt new file mode 100644 index 00000000000..05729c69bde --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt @@ -0,0 +1,43 @@ +// ALLOW_KOTLIN_PACKAGE + +// MODULE: sandbox +// FILE: sandbox/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module sandbox { + requires java9_annotations; + exports test; +} + +// FILE: sandbox/test/package-info.java +package test; + +// FILE: sandbox/test/Foo.java +package test; + +class Foo {} + +// MODULE: sandbox2 +// FILE: sandbox2/module-info.java +module sandbox2 { + requires java9_annotations; + exports test; +} + +// FILE: sandbox2/test/package-info.java +package test; + +// FILE: sandbox2/test/Test.java +package test; + +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +import test.Test + +fun main(x: Test) { + x.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.txt new file mode 100644 index 00000000000..8ecab7ee55c --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.txt @@ -0,0 +1,29 @@ +// -- Module: -- +package + +package test { + + public/*package*/ open class Foo { + public/*package*/ constructor Foo() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +// -- Module: -- +package + +public fun main(/*0*/ x: test.Test): kotlin.Unit + +package test { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dotNamedModule.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dotNamedModule.kt new file mode 100644 index 00000000000..ca5497ed6ff --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dotNamedModule.kt @@ -0,0 +1,24 @@ +// ALLOW_KOTLIN_PACKAGE + +// FILE: my.sand.box/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +open module my.sand.box { + requires java9_annotations; + exports my.test; +} + +// FILE: my.sand.box/my/test/Test.java +package my.test; + +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +import my.test.Test + +fun main(x: Test) { + x.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dotNamedModule.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dotNamedModule.txt new file mode 100644 index 00000000000..0756c89d246 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dotNamedModule.txt @@ -0,0 +1,18 @@ +package + +public fun main(/*0*/ x: my.test.Test): kotlin.Unit + +package my { + + package my.test { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.kt new file mode 100644 index 00000000000..1f97c243560 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.kt @@ -0,0 +1,44 @@ +// ALLOW_KOTLIN_PACKAGE + +// MODULE: module1 +// FILE: module1/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module module1 { + requires java9_annotations; + exports test1; +} + +// FILE: module1/test1/Test1.java +package test1; + +public class Test1 { + public void foo(Integer x) {} +} + +// MODULE: module2(module1) +// FILE: module2/module-info.java +module module2 { + requires module1; + exports test2; +} + +// FILE: module2/test2/Test2.java +package test2; + +import test1.Test1; + +public class Test2 extends Test1 { + public void foo2(Integer x) {} +} + +// FILE: main.kt +import test1.Test1 +import test2.Test2 + +fun main(x: Test1, y: Test2) { + x.foo(null) + y.foo(null) + y.foo2(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.txt new file mode 100644 index 00000000000..fce457e7676 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.txt @@ -0,0 +1,31 @@ +// -- Module: -- +package + +package test1 { + + public open class Test1 { + public constructor Test1() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +// -- Module: -- +package + +public fun main(/*0*/ x: test1.Test1, /*1*/ y: test2.Test2): kotlin.Unit + +package test2 { + + public open class Test2 : test1.Test1 { + public constructor Test2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: kotlin.Int!): kotlin.Unit + public open fun foo2(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/nestedClasses.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/nestedClasses.kt new file mode 100644 index 00000000000..f0a0edd04e7 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/nestedClasses.kt @@ -0,0 +1,42 @@ +// ALLOW_KOTLIN_PACKAGE + +// FILE: sandbox/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module sandbox { + requires java9_annotations; + exports test; +} + +// FILE: sandbox/test/Test.java +package test; + +public class Test { + public static class Test2 { + public Integer foo(Integer x) { return 1; } + public static class Test4 { + public Integer foo(Integer x) { return 1; } + } + public class Test5 { + public Integer foo(Integer x) { return 1; } + } + } + public class Test3 { + public Integer foo(Integer x) { return 1; } + public class Test5 { + public Integer foo(Integer x) { return 1; } + } + } +} + +// FILE: main.kt +import test.Test + +fun main(x: Test) { + x.Test3().foo(null) + x.Test3().Test5().foo(null) + + Test.Test2().foo(null) + Test.Test2().Test5().foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/nestedClasses.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/nestedClasses.txt new file mode 100644 index 00000000000..e5857d9793f --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/nestedClasses.txt @@ -0,0 +1,54 @@ +package + +public fun main(/*0*/ x: test.Test): kotlin.Unit + +package test { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public open class Test2 { + public constructor Test2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Int! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public open class Test4 { + public constructor Test4() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Int! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open inner class Test5 { + public constructor Test5() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Int! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + + public open inner class Test3 { + public constructor Test3() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Int! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public open inner class Test5 { + public constructor Test5() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Int! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/overrideAtDeclarationLevel.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/overrideAtDeclarationLevel.kt new file mode 100644 index 00000000000..4624ab6a1cd --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/overrideAtDeclarationLevel.kt @@ -0,0 +1,26 @@ +// ALLOW_KOTLIN_PACKAGE + +// FILE: sandbox/test/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module sandbox { + requires java9_annotations; + exports test; +} + +// FILE: sandbox/test/Test.java +package test; + +import org.jspecify.nullness.Nullable; + +public class Test { + public void foo(@Nullable Integer x) {} +} + +// FILE: main.kt +import test.Test + +fun main(x: Test) { + x.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/overrideAtDeclarationLevel.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/overrideAtDeclarationLevel.txt new file mode 100644 index 00000000000..f73f078d963 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/overrideAtDeclarationLevel.txt @@ -0,0 +1,15 @@ +package + +public fun main(/*0*/ x: test.Test): kotlin.Unit + +package test { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ @org.jspecify.nullness.Nullable x: @org.jspecify.nullness.Nullable kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.kt new file mode 100644 index 00000000000..83b6117cfa0 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.kt @@ -0,0 +1,38 @@ +// ALLOW_KOTLIN_PACKAGE + +// MODULE: module1 +// FILE: module1/module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module module1 { + requires java9_annotations; + exports test1; +} + +// FILE: module1/test1/Test.java +package test1; + +public class Test { + public void foo(Integer x) {} +} + +// MODULE: module2(module1) +// FILE: module2/module-info.java +module module2 { + requires module1; + exports test2; +} + +// FILE: module2/test2/Test.java +package test2; + +public class Test { + public void foo(Integer x) {} +} + +// FILE: main.kt +fun main(x: test1.Test, y: test2.Test) { + x.foo(null) + y.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.txt new file mode 100644 index 00000000000..f16e1e80fd2 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.txt @@ -0,0 +1,30 @@ +// -- Module: -- +package + +package test1 { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +// -- Module: -- +package + +public fun main(/*0*/ x: test1.Test, /*1*/ y: test2.Test): kotlin.Unit + +package test2 { + + public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.kt deleted file mode 100644 index b520047a76d..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.kt +++ /dev/null @@ -1,19 +0,0 @@ -// ALLOW_KOTLIN_PACKAGE - -// FILE: module-info.java -import org.jspecify.nullness.NullMarked; - -@NullMarked -module sandbox { - requires java9_annotations; -} - -// FILE: Test.java -public class Test { - void foo(Integer x) {} -} - -// FILE: main.kt -fun main(x: Test) { - x.foo(1) -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.txt deleted file mode 100644 index fdf763e20ed..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.txt +++ /dev/null @@ -1,11 +0,0 @@ -package - -public fun main(/*0*/ x: Test): kotlin.Unit - -public open class Test { - public constructor Test() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public/*package*/ open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java index cbe37957c25..928b3a3e852 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java @@ -1070,16 +1070,176 @@ public class ForeignAnnotationsCompiledJavaTestGenerated extends AbstractForeign KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests"), Pattern.compile("^(.+)\\.kt$"), null, true); } - @Test - @TestMetadata("binaryModuleInfoAnnotation.kt") - public void testBinaryModuleInfoAnnotation() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.kt"); - } + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify") + @TestDataPath("$PROJECT_ROOT") + public class Jspecify { + @Test + public void testAllFilesPresentInJspecify() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify"), Pattern.compile("^(.+)\\.kt$"), null, true); + } - @Test - @TestMetadata("sourceModuleInfoAnnotation.kt") - public void testSourceModuleInfoAnnotation() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.kt"); + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations") + @TestDataPath("$PROJECT_ROOT") + public class ModuleAnnotations { + @Test + public void testAllFilesPresentInModuleAnnotations() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict") + @TestDataPath("$PROJECT_ROOT") + public class Strict { + @Test + public void testAllFilesPresentInStrict() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("basic.kt") + public void testBasic() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/basic.kt"); + } + + @Test + @TestMetadata("composeWithClassDefaultAnnotation.kt") + public void testComposeWithClassDefaultAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithClassDefaultAnnotation.kt"); + } + + @Test + @TestMetadata("composeWithPackageDefaultAnnotation.kt") + public void testComposeWithPackageDefaultAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithPackageDefaultAnnotation.kt"); + } + + @Test + @TestMetadata("dependentModulesNoNullMarked.kt") + public void testDependentModulesNoNullMarked() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNoNullMarked.kt"); + } + + @Test + @TestMetadata("dependentModulesNullMarked.kt") + public void testDependentModulesNullMarked() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNullMarked.kt"); + } + + @Test + @TestMetadata("dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt") + public void testDontPropagateModuleAnnotationToAnotherModuleWithSamePackage() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt"); + } + + @Test + @TestMetadata("dotNamedModule.kt") + public void testDotNamedModule() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dotNamedModule.kt"); + } + + @Test + @TestMetadata("inheritanceAcrossModules.kt") + public void testInheritanceAcrossModules() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/inheritanceAcrossModules.kt"); + } + + @Test + @TestMetadata("nestedClasses.kt") + public void testNestedClasses() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/nestedClasses.kt"); + } + + @Test + @TestMetadata("overrideAtDeclarationLevel.kt") + public void testOverrideAtDeclarationLevel() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/overrideAtDeclarationLevel.kt"); + } + + @Test + @TestMetadata("severalModulesDifferentPackages.kt") + public void testSeveralModulesDifferentPackages() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/severalModulesDifferentPackages.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn") + @TestDataPath("$PROJECT_ROOT") + public class Warn { + @Test + public void testAllFilesPresentInWarn() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("basic.kt") + public void testBasic() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/basic.kt"); + } + + @Test + @TestMetadata("composeWithClassDefaultAnnotation.kt") + public void testComposeWithClassDefaultAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.kt"); + } + + @Test + @TestMetadata("composeWithPackageDefaultAnnotation.kt") + public void testComposeWithPackageDefaultAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.kt"); + } + + @Test + @TestMetadata("dependentModulesNoNullMarked.kt") + public void testDependentModulesNoNullMarked() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNoNullMarked.kt"); + } + + @Test + @TestMetadata("dependentModulesNullMarked.kt") + public void testDependentModulesNullMarked() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.kt"); + } + + @Test + @TestMetadata("dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt") + public void testDontPropagateModuleAnnotationToAnotherModuleWithSamePackage() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt"); + } + + @Test + @TestMetadata("dotNamedModule.kt") + public void testDotNamedModule() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dotNamedModule.kt"); + } + + @Test + @TestMetadata("inheritanceAcrossModules.kt") + public void testInheritanceAcrossModules() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.kt"); + } + + @Test + @TestMetadata("nestedClasses.kt") + public void testNestedClasses() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/nestedClasses.kt"); + } + + @Test + @TestMetadata("overrideAtDeclarationLevel.kt") + public void testOverrideAtDeclarationLevel() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/overrideAtDeclarationLevel.kt"); + } + + @Test + @TestMetadata("severalModulesDifferentPackages.kt") + public void testSeveralModulesDifferentPackages() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.kt"); + } + } + } } } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java index d40a328e56a..78f0bcc7195 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java @@ -1070,16 +1070,176 @@ public class ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated exte KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests"), Pattern.compile("^(.+)\\.kt$"), null, true); } - @Test - @TestMetadata("binaryModuleInfoAnnotation.kt") - public void testBinaryModuleInfoAnnotation() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.kt"); - } + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify") + @TestDataPath("$PROJECT_ROOT") + public class Jspecify { + @Test + public void testAllFilesPresentInJspecify() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify"), Pattern.compile("^(.+)\\.kt$"), null, true); + } - @Test - @TestMetadata("sourceModuleInfoAnnotation.kt") - public void testSourceModuleInfoAnnotation() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.kt"); + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations") + @TestDataPath("$PROJECT_ROOT") + public class ModuleAnnotations { + @Test + public void testAllFilesPresentInModuleAnnotations() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict") + @TestDataPath("$PROJECT_ROOT") + public class Strict { + @Test + public void testAllFilesPresentInStrict() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("basic.kt") + public void testBasic() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/basic.kt"); + } + + @Test + @TestMetadata("composeWithClassDefaultAnnotation.kt") + public void testComposeWithClassDefaultAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithClassDefaultAnnotation.kt"); + } + + @Test + @TestMetadata("composeWithPackageDefaultAnnotation.kt") + public void testComposeWithPackageDefaultAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithPackageDefaultAnnotation.kt"); + } + + @Test + @TestMetadata("dependentModulesNoNullMarked.kt") + public void testDependentModulesNoNullMarked() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNoNullMarked.kt"); + } + + @Test + @TestMetadata("dependentModulesNullMarked.kt") + public void testDependentModulesNullMarked() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNullMarked.kt"); + } + + @Test + @TestMetadata("dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt") + public void testDontPropagateModuleAnnotationToAnotherModuleWithSamePackage() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt"); + } + + @Test + @TestMetadata("dotNamedModule.kt") + public void testDotNamedModule() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dotNamedModule.kt"); + } + + @Test + @TestMetadata("inheritanceAcrossModules.kt") + public void testInheritanceAcrossModules() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/inheritanceAcrossModules.kt"); + } + + @Test + @TestMetadata("nestedClasses.kt") + public void testNestedClasses() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/nestedClasses.kt"); + } + + @Test + @TestMetadata("overrideAtDeclarationLevel.kt") + public void testOverrideAtDeclarationLevel() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/overrideAtDeclarationLevel.kt"); + } + + @Test + @TestMetadata("severalModulesDifferentPackages.kt") + public void testSeveralModulesDifferentPackages() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/severalModulesDifferentPackages.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn") + @TestDataPath("$PROJECT_ROOT") + public class Warn { + @Test + public void testAllFilesPresentInWarn() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("basic.kt") + public void testBasic() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/basic.kt"); + } + + @Test + @TestMetadata("composeWithClassDefaultAnnotation.kt") + public void testComposeWithClassDefaultAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.kt"); + } + + @Test + @TestMetadata("composeWithPackageDefaultAnnotation.kt") + public void testComposeWithPackageDefaultAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.kt"); + } + + @Test + @TestMetadata("dependentModulesNoNullMarked.kt") + public void testDependentModulesNoNullMarked() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNoNullMarked.kt"); + } + + @Test + @TestMetadata("dependentModulesNullMarked.kt") + public void testDependentModulesNullMarked() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.kt"); + } + + @Test + @TestMetadata("dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt") + public void testDontPropagateModuleAnnotationToAnotherModuleWithSamePackage() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt"); + } + + @Test + @TestMetadata("dotNamedModule.kt") + public void testDotNamedModule() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dotNamedModule.kt"); + } + + @Test + @TestMetadata("inheritanceAcrossModules.kt") + public void testInheritanceAcrossModules() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.kt"); + } + + @Test + @TestMetadata("nestedClasses.kt") + public void testNestedClasses() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/nestedClasses.kt"); + } + + @Test + @TestMetadata("overrideAtDeclarationLevel.kt") + public void testOverrideAtDeclarationLevel() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/overrideAtDeclarationLevel.kt"); + } + + @Test + @TestMetadata("severalModulesDifferentPackages.kt") + public void testSeveralModulesDifferentPackages() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.kt"); + } + } + } } } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java index 963bca54819..5ee316e022b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java @@ -1070,16 +1070,176 @@ public class ForeignAnnotationsSourceJavaTestGenerated extends AbstractForeignAn KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests"), Pattern.compile("^(.+)\\.kt$"), null, true); } - @Test - @TestMetadata("binaryModuleInfoAnnotation.kt") - public void testBinaryModuleInfoAnnotation() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.kt"); - } + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify") + @TestDataPath("$PROJECT_ROOT") + public class Jspecify { + @Test + public void testAllFilesPresentInJspecify() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify"), Pattern.compile("^(.+)\\.kt$"), null, true); + } - @Test - @TestMetadata("sourceModuleInfoAnnotation.kt") - public void testSourceModuleInfoAnnotation() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.kt"); + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations") + @TestDataPath("$PROJECT_ROOT") + public class ModuleAnnotations { + @Test + public void testAllFilesPresentInModuleAnnotations() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict") + @TestDataPath("$PROJECT_ROOT") + public class Strict { + @Test + public void testAllFilesPresentInStrict() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("basic.kt") + public void testBasic() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/basic.kt"); + } + + @Test + @TestMetadata("composeWithClassDefaultAnnotation.kt") + public void testComposeWithClassDefaultAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithClassDefaultAnnotation.kt"); + } + + @Test + @TestMetadata("composeWithPackageDefaultAnnotation.kt") + public void testComposeWithPackageDefaultAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/composeWithPackageDefaultAnnotation.kt"); + } + + @Test + @TestMetadata("dependentModulesNoNullMarked.kt") + public void testDependentModulesNoNullMarked() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNoNullMarked.kt"); + } + + @Test + @TestMetadata("dependentModulesNullMarked.kt") + public void testDependentModulesNullMarked() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dependentModulesNullMarked.kt"); + } + + @Test + @TestMetadata("dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt") + public void testDontPropagateModuleAnnotationToAnotherModuleWithSamePackage() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt"); + } + + @Test + @TestMetadata("dotNamedModule.kt") + public void testDotNamedModule() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/dotNamedModule.kt"); + } + + @Test + @TestMetadata("inheritanceAcrossModules.kt") + public void testInheritanceAcrossModules() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/inheritanceAcrossModules.kt"); + } + + @Test + @TestMetadata("nestedClasses.kt") + public void testNestedClasses() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/nestedClasses.kt"); + } + + @Test + @TestMetadata("overrideAtDeclarationLevel.kt") + public void testOverrideAtDeclarationLevel() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/overrideAtDeclarationLevel.kt"); + } + + @Test + @TestMetadata("severalModulesDifferentPackages.kt") + public void testSeveralModulesDifferentPackages() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/strict/severalModulesDifferentPackages.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn") + @TestDataPath("$PROJECT_ROOT") + public class Warn { + @Test + public void testAllFilesPresentInWarn() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("basic.kt") + public void testBasic() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/basic.kt"); + } + + @Test + @TestMetadata("composeWithClassDefaultAnnotation.kt") + public void testComposeWithClassDefaultAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.kt"); + } + + @Test + @TestMetadata("composeWithPackageDefaultAnnotation.kt") + public void testComposeWithPackageDefaultAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.kt"); + } + + @Test + @TestMetadata("dependentModulesNoNullMarked.kt") + public void testDependentModulesNoNullMarked() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNoNullMarked.kt"); + } + + @Test + @TestMetadata("dependentModulesNullMarked.kt") + public void testDependentModulesNullMarked() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.kt"); + } + + @Test + @TestMetadata("dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt") + public void testDontPropagateModuleAnnotationToAnotherModuleWithSamePackage() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dontPropagateModuleAnnotationToAnotherModuleWithSamePackage.kt"); + } + + @Test + @TestMetadata("dotNamedModule.kt") + public void testDotNamedModule() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/dotNamedModule.kt"); + } + + @Test + @TestMetadata("inheritanceAcrossModules.kt") + public void testInheritanceAcrossModules() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.kt"); + } + + @Test + @TestMetadata("nestedClasses.kt") + public void testNestedClasses() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/nestedClasses.kt"); + } + + @Test + @TestMetadata("overrideAtDeclarationLevel.kt") + public void testOverrideAtDeclarationLevel() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/overrideAtDeclarationLevel.kt"); + } + + @Test + @TestMetadata("severalModulesDifferentPackages.kt") + public void testSeveralModulesDifferentPackages() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.kt"); + } + } + } } } } diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/typeEnhancement/signatureEnhancement.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/typeEnhancement/signatureEnhancement.kt index 1479e097ed0..ddc23f58b7a 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/typeEnhancement/signatureEnhancement.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/typeEnhancement/signatureEnhancement.kt @@ -19,10 +19,7 @@ package org.jetbrains.kotlin.load.java.typeEnhancement import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMapper import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.descriptors.annotations.Annotated -import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor -import org.jetbrains.kotlin.descriptors.annotations.Annotations -import org.jetbrains.kotlin.descriptors.annotations.composeAnnotations +import org.jetbrains.kotlin.descriptors.annotations.* import org.jetbrains.kotlin.load.java.* import org.jetbrains.kotlin.load.java.descriptors.* import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext @@ -36,8 +33,7 @@ import org.jetbrains.kotlin.load.kotlin.signature import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.constants.EnumValue import org.jetbrains.kotlin.resolve.deprecation.DEPRECATED_FUNCTION_KEY -import org.jetbrains.kotlin.resolve.descriptorUtil.firstArgument -import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull +import org.jetbrains.kotlin.resolve.descriptorUtil.* import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.typeUtil.contains @@ -152,6 +148,18 @@ class SignatureEnhancement( } } + private fun D.getDefaultAnnotations(c: LazyJavaResolverContext): Annotations { + val topLevelClassifier = getTopLevelContainingClassifier() ?: return annotations + val classId = topLevelClassifier.classId ?: return annotations + val moduleAnnotations = c.components.javaModuleResolver.getModuleAnnotations(classId) + + if (moduleAnnotations.isNullOrEmpty()) return annotations + + val moduleAnnotationDescriptors = moduleAnnotations.map { LazyJavaAnnotationDescriptor(c, it, isFreshlySupportedAnnotation = true) } + + return Annotations.create(annotations + moduleAnnotationDescriptors) + } + private fun D.enhanceSignature(c: LazyJavaResolverContext): D { // TODO type parameters // TODO use new type parameters while enhancing other types @@ -162,7 +170,7 @@ class SignatureEnhancement( // Fake overrides with one overridden has been enhanced before if (kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE && original.overriddenDescriptors.size == 1) return this - val memberContext = c.copyWithNewDefaultTypeQualifiers(annotations) + val memberContext = c.copyWithNewDefaultTypeQualifiers(getDefaultAnnotations(c)) // When loading method as an override for a property, all annotations are stick to its getter val annotationOwnerForMember = diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/descriptorUtil.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/descriptorUtil.kt index 81062155718..fba3f720907 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/descriptorUtil.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/descriptorUtil.kt @@ -58,6 +58,20 @@ fun DeclarationDescriptor.isTopLevelInPackage(name: String, packageName: String) return packageName == packageFqName } +fun DeclarationDescriptor.isTopLevelInPackage() = containingDeclaration is PackageFragmentDescriptor + +fun DeclarationDescriptor.getTopLevelContainingClassifier(): ClassifierDescriptor? { + val containingDeclaration = containingDeclaration + + if (containingDeclaration == null || this is PackageFragmentDescriptor) return null + + return if (!containingDeclaration.isTopLevelInPackage()) { + containingDeclaration.getTopLevelContainingClassifier() + } else if (containingDeclaration is ClassifierDescriptor) { + containingDeclaration + } else null +} + fun CallableDescriptor.isSupportedForCallableReference() = this is PropertyDescriptor || this is FunctionDescriptor @OptIn(ExperimentalContracts::class)