diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/lightClassUtils.kt b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/lightClassUtils.kt index df4f4cea606..a2ffab29fd1 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/lightClassUtils.kt +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/lightClassUtils.kt @@ -241,7 +241,7 @@ fun fastCheckIsNullabilityApplied(lightElement: KtLightElement<*, PsiModifierLis // backing fields for lateinit props are skipped if (lightElement is KtLightField && annotatedElement is KtProperty && annotatedElement.hasModifier(KtTokens.LATEINIT_KEYWORD)) return false - if (lightElement is KtLightField && (annotatedElement as? KtModifierListOwner)?.isPrivate() == true) { + if (lightElement is KtLightMethod && (annotatedElement as? KtModifierListOwner)?.isPrivate() == true) { return false } @@ -252,16 +252,17 @@ fun fastCheckIsNullabilityApplied(lightElement: KtLightElement<*, PsiModifierLis if (annotatedElement.parent.parent is KtPrimaryConstructor) return false } - val parent = annotatedElement.parent.parent - if (parent is KtModifierListOwner && parent !is KtPrimaryConstructor && parent.isPrivate()) return false - - if (parent is KtPropertyAccessor) { - val propertyOfAccessor = parent.parent - if (propertyOfAccessor is KtProperty && propertyOfAccessor.isPrivate()) return false + when (val parent = annotatedElement.parent.parent) { + is KtConstructor<*> -> { + if (lightElement is KtLightParameter && parent.isPrivate()) return false + } + is KtNamedFunction -> { + return !parent.isPrivate() + } + is KtPropertyAccessor -> { + return (parent.parent as? KtProperty)?.isPrivate() != true + } } - } else { - // private properties - if ((annotatedElement as? KtModifierListOwner)?.isPrivate() == true) return false } return true diff --git a/compiler/testData/asJava/lightClasses/AnnotatedPropertyWithSites.kt b/compiler/testData/asJava/lightClasses/AnnotatedPropertyWithSites.kt index 4d21f84c924..f49c1845ab8 100644 --- a/compiler/testData/asJava/lightClasses/AnnotatedPropertyWithSites.kt +++ b/compiler/testData/asJava/lightClasses/AnnotatedPropertyWithSites.kt @@ -14,4 +14,6 @@ class Test(@get:MyAnnotation @set:MyAnnotation2 @setparam:MyAnnotation3 @propert var @receiver:MyAnnotation7 Int.fooP get() = Unit set(value) {} -} \ No newline at end of file +} + +// FIR_COMPARISON \ No newline at end of file diff --git a/compiler/testData/asJava/lightClasses/DelegatedNested.java b/compiler/testData/asJava/lightClasses/DelegatedNested.java index 404ceb2a2f5..08db1963340 100644 --- a/compiler/testData/asJava/lightClasses/DelegatedNested.java +++ b/compiler/testData/asJava/lightClasses/DelegatedNested.java @@ -3,6 +3,7 @@ public final class B /* p.B*/ { public static final class A /* p.B.A*/ implements p.I { + @org.jetbrains.annotations.NotNull() private final p.I f; public A(@org.jetbrains.annotations.NotNull() p.I);// .ctor(p.I) diff --git a/compiler/testData/asJava/lightClasses/Delegation.java b/compiler/testData/asJava/lightClasses/Delegation.java index cb3e779e47d..3bfff25e8c4 100644 --- a/compiler/testData/asJava/lightClasses/Delegation.java +++ b/compiler/testData/asJava/lightClasses/Delegation.java @@ -1,4 +1,5 @@ public final class B /* p.B*/ implements p.I { + @org.jetbrains.annotations.NotNull() private final p.I f; public B(@org.jetbrains.annotations.NotNull() p.I);// .ctor(p.I) diff --git a/compiler/testData/asJava/lightClasses/compilationErrors/SameName.java b/compiler/testData/asJava/lightClasses/compilationErrors/SameName.java index 65a662f1d11..880b0e98ae5 100644 --- a/compiler/testData/asJava/lightClasses/compilationErrors/SameName.java +++ b/compiler/testData/asJava/lightClasses/compilationErrors/SameName.java @@ -1,12 +1,15 @@ public final class A /* A*/ { - private final int i; - + @org.jetbrains.annotations.NotNull() private final java.lang.String i$1; + @org.jetbrains.annotations.NotNull() private final java.lang.String j$1; + @org.jetbrains.annotations.NotNull() private final java.lang.String j; + private final int i; + @org.jetbrains.annotations.NotNull() public final java.lang.String g(int, double);// g(int, double) diff --git a/compiler/testData/asJava/lightClasses/compilationErrors/TraitClassObjectField.java b/compiler/testData/asJava/lightClasses/compilationErrors/TraitClassObjectField.java index da5740db940..ef6c8127b55 100644 --- a/compiler/testData/asJava/lightClasses/compilationErrors/TraitClassObjectField.java +++ b/compiler/testData/asJava/lightClasses/compilationErrors/TraitClassObjectField.java @@ -8,10 +8,11 @@ public abstract interface TraitClassObjectField /* TraitClassObjectField*/ { public static final class Companion /* TraitClassObjectField.Companion*/ { @org.jetbrains.annotations.Nullable() - public static final java.lang.String x = "" /* initializer type: java.lang.String */ /* constant value */; - private static final java.lang.String y; + @org.jetbrains.annotations.Nullable() + public static final java.lang.String x = "" /* initializer type: java.lang.String */ /* constant value */; + private Companion();// .ctor() }} \ No newline at end of file diff --git a/compiler/testData/asJava/lightClasses/ideRegression/ImplementingMutableSet.java b/compiler/testData/asJava/lightClasses/ideRegression/ImplementingMutableSet.java index 5d7a414d19e..9e0b7b4dc18 100644 --- a/compiler/testData/asJava/lightClasses/ideRegression/ImplementingMutableSet.java +++ b/compiler/testData/asJava/lightClasses/ideRegression/ImplementingMutableSet.java @@ -2,10 +2,11 @@ public final class SmartSet /* SmartSet*/ extends kotlin.collections.Abstrac @org.jetbrains.annotations.NotNull() public static final SmartSet.Companion Companion; - private int size; - + @org.jetbrains.annotations.Nullable() private java.lang.Object data; + private int size; + private static final int ARRAY_THRESHOLD; @kotlin.jvm.JvmStatic() diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/Class.java b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/Class.java index 4727cba5cd5..5c2069217b4 100644 --- a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/Class.java +++ b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/Class.java @@ -2,6 +2,9 @@ public final class Class /* Class*/ { @org.jetbrains.annotations.NotNull() private final java.lang.String notNullVal; + @org.jetbrains.annotations.NotNull() + private final java.lang.String privateNN; + @org.jetbrains.annotations.NotNull() private java.lang.String notNullVar; @@ -9,11 +12,10 @@ public final class Class /* Class*/ { private final java.lang.String nullableVal; @org.jetbrains.annotations.Nullable() - private java.lang.String nullableVar; - private final java.lang.String privateN; - private final java.lang.String privateNN; + @org.jetbrains.annotations.Nullable() + private java.lang.String nullableVar; public java.lang.String lateInitVar; diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassObjectField.java b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassObjectField.java index f1b8563a0ee..8b185e2cb6c 100644 --- a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassObjectField.java +++ b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassObjectField.java @@ -5,6 +5,7 @@ public final class ClassObjectField /* ClassObjectField*/ { @org.jetbrains.annotations.Nullable() private static final java.lang.String x; + @org.jetbrains.annotations.Nullable() private static final java.lang.String y; public ClassObjectField();// .ctor() diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassWithConstructorAndProperties.kt b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassWithConstructorAndProperties.kt index 91e7411e0a3..0372ff962b6 100644 --- a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassWithConstructorAndProperties.kt +++ b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassWithConstructorAndProperties.kt @@ -4,3 +4,5 @@ class ClassWithConstructorAndProperties( val nullable: String?, val notNull: String ) + +// FIR_COMPARISON \ No newline at end of file diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/FileFacade.java b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/FileFacade.java index 8380d0aaf40..dcfb679fa05 100644 --- a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/FileFacade.java +++ b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/FileFacade.java @@ -2,6 +2,9 @@ public final class FileFacadeKt /* FileFacadeKt*/ { @org.jetbrains.annotations.NotNull() private static final java.lang.String notNullVal; + @org.jetbrains.annotations.NotNull() + private static final java.lang.String privateNn; + @org.jetbrains.annotations.NotNull() private static java.lang.String notNullVar; @@ -9,11 +12,10 @@ public final class FileFacadeKt /* FileFacadeKt*/ { private static final java.lang.String nullableVal; @org.jetbrains.annotations.Nullable() - private static java.lang.String nullableVar; - private static final java.lang.String privateN; - private static final java.lang.String privateNn; + @org.jetbrains.annotations.Nullable() + private static java.lang.String nullableVar; @org.jetbrains.annotations.NotNull() @org.jetbrains.annotations.Nullable() diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/FileFacade.kt b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/FileFacade.kt index 701c8a635bd..c912d8c0b15 100644 --- a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/FileFacade.kt +++ b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/FileFacade.kt @@ -33,4 +33,6 @@ var nullableVarWithGetSet: String? private val privateNn: String = { "" }() private val privateN: String? = { "" }() -private fun privateFun(a: String, b: String?): String? = null \ No newline at end of file +private fun privateFun(a: String, b: String?): String? = null + +// FIR_COMPARISON \ No newline at end of file diff --git a/compiler/testData/asJava/ultraLightClasses/inferringAnonymousObjectTypes.java b/compiler/testData/asJava/ultraLightClasses/inferringAnonymousObjectTypes.java index 6553e0edb46..e6cfaa9cf8f 100644 --- a/compiler/testData/asJava/ultraLightClasses/inferringAnonymousObjectTypes.java +++ b/compiler/testData/asJava/ultraLightClasses/inferringAnonymousObjectTypes.java @@ -1,4 +1,5 @@ public final class Prop /* Prop*/ { + @org.jetbrains.annotations.NotNull() private final java.lang.Object someProp; public Prop();// .ctor() diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 512185ca7b3..c6bb76dc039 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -1320,8 +1320,8 @@ fun main(args: Array) { testClass { model( "asJava/lightClasses", - excludeDirs = listOf("local", "compilationErrors", "ideRegression"), - pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME + excludeDirs = listOf("local", "compilationErrors", "ideRegression", "script"), + pattern = KT_WITHOUT_DOTS_IN_NAME ) } } diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as42 b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as42 index c031f4481e0..ad38f939289 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as42 +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as42 @@ -885,7 +885,7 @@ fun main(args: Array) { } testClass { - model("asJava/lightClasses", excludeDirs = listOf("local", "compilationErrors", "ideRegression"), pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME) + model("asJava/lightClasses", excludeDirs = listOf("local", "compilationErrors", "ideRegression", "script"), pattern = KT_WITHOUT_DOTS_IN_NAME) } } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/fields/FirLightFieldForPropertySymbol.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/fields/FirLightFieldForPropertySymbol.kt index 1de38967fbf..74284f0e601 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/fields/FirLightFieldForPropertySymbol.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/fields/FirLightFieldForPropertySymbol.kt @@ -83,7 +83,7 @@ internal class FirLightFieldForPropertySymbol( modifiers.add(PsiModifier.VOLATILE) } - val nullability = if (visibility != PsiModifier.PRIVATE && !(propertySymbol is KtKotlinPropertySymbol && propertySymbol.isLateInit)) + val nullability = if (!(propertySymbol is KtKotlinPropertySymbol && propertySymbol.isLateInit)) propertySymbol.annotatedType.type.getTypeNullability(propertySymbol, FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) else NullabilityType.Unknown diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/IdeCompiledLightClassTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/IdeCompiledLightClassTestGenerated.java index 90778617ed2..7d130e525d0 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/IdeCompiledLightClassTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/IdeCompiledLightClassTestGenerated.java @@ -26,7 +26,7 @@ public class IdeCompiledLightClassTestGenerated extends AbstractIdeCompiledLight } public void testAllFilesPresentInLightClasses() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/asJava/lightClasses"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true, "local", "compilationErrors", "ideRegression"); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/asJava/lightClasses"), Pattern.compile("^([^.]+)\\.kt$"), null, true, "local", "compilationErrors", "ideRegression", "script"); } @TestMetadata("AnnotatedParameterInEnumConstructor.kt") @@ -178,7 +178,7 @@ public class IdeCompiledLightClassTestGenerated extends AbstractIdeCompiledLight } public void testAllFilesPresentInDelegation() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/asJava/lightClasses/delegation"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/asJava/lightClasses/delegation"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } @TestMetadata("Function.kt") @@ -201,7 +201,7 @@ public class IdeCompiledLightClassTestGenerated extends AbstractIdeCompiledLight } public void testAllFilesPresentInFacades() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/asJava/lightClasses/facades"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/asJava/lightClasses/facades"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } @TestMetadata("AllPrivate.kt") @@ -234,7 +234,7 @@ public class IdeCompiledLightClassTestGenerated extends AbstractIdeCompiledLight } public void testAllFilesPresentInNullabilityAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/asJava/lightClasses/nullabilityAnnotations"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/asJava/lightClasses/nullabilityAnnotations"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } @TestMetadata("Class.kt") @@ -337,7 +337,7 @@ public class IdeCompiledLightClassTestGenerated extends AbstractIdeCompiledLight } public void testAllFilesPresentInObject() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/asJava/lightClasses/object"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/asJava/lightClasses/object"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } @TestMetadata("SimpleObject.kt") @@ -355,7 +355,7 @@ public class IdeCompiledLightClassTestGenerated extends AbstractIdeCompiledLight } public void testAllFilesPresentInPublicField() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/asJava/lightClasses/publicField"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/asJava/lightClasses/publicField"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } @TestMetadata("CompanionObject.kt") @@ -368,27 +368,4 @@ public class IdeCompiledLightClassTestGenerated extends AbstractIdeCompiledLight runTest("compiler/testData/asJava/lightClasses/publicField/Simple.kt"); } } - - @TestMetadata("compiler/testData/asJava/lightClasses/script") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Script extends AbstractIdeCompiledLightClassTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInScript() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/asJava/lightClasses/script"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true); - } - - @TestMetadata("HelloWorld.kts") - public void testHelloWorld() throws Exception { - runTest("compiler/testData/asJava/lightClasses/script/HelloWorld.kts"); - } - - @TestMetadata("InnerClasses.kts") - public void testInnerClasses() throws Exception { - runTest("compiler/testData/asJava/lightClasses/script/InnerClasses.kts"); - } - } } diff --git a/tests/mute-common.csv b/tests/mute-common.csv index 4fe4fd0d3e9..9fafe02ee41 100644 --- a/tests/mute-common.csv +++ b/tests/mute-common.csv @@ -97,13 +97,6 @@ org.jetbrains.kotlin.jps.build.KotlinJpsBuildTestIncremental.testCircularDepende org.jetbrains.kotlin.jps.build.KotlinJpsBuildTestIncremental.testCircularDependenciesSamePackageWithTests, Temporary muted due to problems with IC and JVM IR backend,, org.jetbrains.kotlin.jps.build.KotlinJpsBuildTestIncremental.testCircularDependenciesWrongInternalFromTests, Temporary muted due to problems with IC and JVM IR backend,, org.jetbrains.kotlin.jps.build.KotlinJpsBuildTestIncremental.testCircularDependencyWithReferenceToOldVersionLib, Temporary muted due to problems with IC and JVM IR backend,, -org.jetbrains.kotlin.idea.caches.resolve.IdeCompiledLightClassTestGenerated.NullabilityAnnotations.testClass, KT-44472,, -org.jetbrains.kotlin.idea.caches.resolve.IdeCompiledLightClassTestGenerated.NullabilityAnnotations.testClassObjectField, KT-44472,, -org.jetbrains.kotlin.idea.caches.resolve.IdeCompiledLightClassTestGenerated.NullabilityAnnotations.testFileFacade, KT-44472,, -org.jetbrains.kotlin.idea.caches.resolve.IdeCompiledLightClassTestGenerated.Script.testHelloWorld, KT-44472,, -org.jetbrains.kotlin.idea.caches.resolve.IdeCompiledLightClassTestGenerated.Script.testInnerClasses, KT-44472,, -org.jetbrains.kotlin.idea.caches.resolve.IdeCompiledLightClassTestGenerated.testDelegatedNested, KT-44472,, -org.jetbrains.kotlin.idea.caches.resolve.IdeCompiledLightClassTestGenerated.testDelegation, KT-44472,, org.jetbrains.kotlin.jps.build.IncrementalJvmJpsTestGenerated.WithJava.JavaUsedInKotlin.SamConversions.testMethodAdded, KT-44844 fixed in IDEA 212,, org.jetbrains.kotlin.jps.build.IncrementalJvmJpsTestGenerated.WithJava.JavaUsedInKotlin.SamConversions.testMethodAddedSamAdapter, KT-44844 fixed in IDEA 212,, org.jetbrains.kotlin.jps.build.IncrementalJvmJpsTestGenerated.WithJava.JavaUsedInKotlin.SamConversions.testMethodSignatureChanged, KT-44844 fixed in IDEA 212,,