K2: introduce JavaTypeParameterDefaultRepresentationWithDNN exp. feature
#KT-66447 Fixed
This commit is contained in:
committed by
Space Team
parent
4464385fa9
commit
cd20f31810
+48
@@ -21822,12 +21822,24 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePosition.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("flexibleTypeVariablePositionDnnRepresentation.kt")
|
||||
public void testFlexibleTypeVariablePositionDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("futureGet.kt")
|
||||
public void testFutureGet() {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/futureGet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("futureGetDnnRepresentation.kt")
|
||||
public void testFutureGetDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericConstructorWithMultipleBounds.kt")
|
||||
public void testGenericConstructorWithMultipleBounds() {
|
||||
@@ -22104,6 +22116,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableLinkedListToQueueDnnRepresentation.kt")
|
||||
public void testNullableLinkedListToQueueDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableRawTypeWithFlexibleArguments.kt")
|
||||
public void testNullableRawTypeWithFlexibleArguments() {
|
||||
@@ -23157,6 +23175,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("notNullTypeParameterWithKotlinNullableDnnRepresentation.kt")
|
||||
public void testNotNullTypeParameterWithKotlinNullableDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("notNullTypeParameterWithKotlinNullableWarnings.kt")
|
||||
public void testNotNullTypeParameterWithKotlinNullableWarnings() {
|
||||
@@ -26390,6 +26414,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/override/dnnOverridesFlexible.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dnnOverridesFlexibleDnnRepresentation.kt")
|
||||
public void testDnnOverridesFlexibleDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DuplicateMethod.kt")
|
||||
public void testDuplicateMethod() {
|
||||
@@ -27002,6 +27032,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullability.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparingWithWrongNullabilityDnnRepresentation.kt")
|
||||
public void testComparingWithWrongNullabilityDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullabilityDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegateByComplexInheritance.kt")
|
||||
public void testDelegateByComplexInheritance() {
|
||||
@@ -27391,6 +27427,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("singletonDnnRepresentation.kt")
|
||||
public void testSingletonDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("string.kt")
|
||||
public void testString() {
|
||||
@@ -30896,6 +30938,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/samConversions/sameCandidatesFromKotlinAndJavaInOneScope.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sameConversionToGenericWrongNullabilityDnnRepresentation.kt")
|
||||
public void testSameConversionToGenericWrongNullabilityDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("SimpleCorrect.kt")
|
||||
public void testSimpleCorrect() {
|
||||
|
||||
+48
@@ -21828,12 +21828,24 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePosition.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("flexibleTypeVariablePositionDnnRepresentation.kt")
|
||||
public void testFlexibleTypeVariablePositionDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("futureGet.kt")
|
||||
public void testFutureGet() {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/futureGet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("futureGetDnnRepresentation.kt")
|
||||
public void testFutureGetDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericConstructorWithMultipleBounds.kt")
|
||||
public void testGenericConstructorWithMultipleBounds() {
|
||||
@@ -22110,6 +22122,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableLinkedListToQueueDnnRepresentation.kt")
|
||||
public void testNullableLinkedListToQueueDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableRawTypeWithFlexibleArguments.kt")
|
||||
public void testNullableRawTypeWithFlexibleArguments() {
|
||||
@@ -23163,6 +23181,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("notNullTypeParameterWithKotlinNullableDnnRepresentation.kt")
|
||||
public void testNotNullTypeParameterWithKotlinNullableDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("notNullTypeParameterWithKotlinNullableWarnings.kt")
|
||||
public void testNotNullTypeParameterWithKotlinNullableWarnings() {
|
||||
@@ -26396,6 +26420,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/override/dnnOverridesFlexible.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dnnOverridesFlexibleDnnRepresentation.kt")
|
||||
public void testDnnOverridesFlexibleDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DuplicateMethod.kt")
|
||||
public void testDuplicateMethod() {
|
||||
@@ -27008,6 +27038,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullability.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparingWithWrongNullabilityDnnRepresentation.kt")
|
||||
public void testComparingWithWrongNullabilityDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullabilityDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegateByComplexInheritance.kt")
|
||||
public void testDelegateByComplexInheritance() {
|
||||
@@ -27397,6 +27433,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("singletonDnnRepresentation.kt")
|
||||
public void testSingletonDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("string.kt")
|
||||
public void testString() {
|
||||
@@ -30908,6 +30950,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/samConversions/sameCandidatesFromKotlinAndJavaInOneScope.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sameConversionToGenericWrongNullabilityDnnRepresentation.kt")
|
||||
public void testSameConversionToGenericWrongNullabilityDnnRepresentation() {
|
||||
runTest("compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("SimpleCorrect.kt")
|
||||
public void testSimpleCorrect() {
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
package org.jetbrains.kotlin.fir.java
|
||||
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
||||
import org.jetbrains.kotlin.fir.java.enhancement.readOnlyToMutable
|
||||
import org.jetbrains.kotlin.fir.languageVersionSettings
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError
|
||||
import org.jetbrains.kotlin.fir.resolve.toFirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
@@ -111,7 +113,21 @@ private fun JavaType?.toConeTypeProjection(
|
||||
}
|
||||
val upperBound = toConeKotlinTypeForFlexibleBound(session, javaTypeParameterStack, mode, attributes, lowerBound)
|
||||
|
||||
if (isRaw) ConeRawType.create(lowerBound, upperBound) else ConeFlexibleType(lowerBound, upperBound)
|
||||
val finalLowerBound = when {
|
||||
!session.languageVersionSettings.supportsFeature(LanguageFeature.JavaTypeParameterDefaultRepresentationWithDNN) ->
|
||||
lowerBound
|
||||
lowerBound is ConeTypeParameterType ->
|
||||
ConeDefinitelyNotNullType.create(
|
||||
lowerBound, session.typeContext,
|
||||
// Upper bounds might be not initialized properly yet, so we force creating DefinitelyNotNullType
|
||||
// It should not affect semantics, since it would be still a valid type anyway
|
||||
avoidComprehensiveCheck = true,
|
||||
) ?: lowerBound
|
||||
|
||||
else -> lowerBound
|
||||
}
|
||||
|
||||
if (isRaw) ConeRawType.create(finalLowerBound, upperBound) else ConeFlexibleType(finalLowerBound, upperBound)
|
||||
}
|
||||
|
||||
is JavaArrayType -> {
|
||||
|
||||
@@ -6,10 +6,13 @@
|
||||
package org.jetbrains.kotlin.fir.types
|
||||
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionTypeKind
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.modality
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeIntermediateDiagnostic
|
||||
import org.jetbrains.kotlin.fir.isPrimitiveNumberOrUnsignedNumberType
|
||||
import org.jetbrains.kotlin.fir.languageVersionSettings
|
||||
import org.jetbrains.kotlin.fir.resolve.createSubstitutionForSupertype
|
||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
|
||||
@@ -587,7 +590,9 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
||||
return intersectionType.withAlternative(secondCandidate)
|
||||
}
|
||||
|
||||
override fun useRefinedBoundsForTypeVariableInFlexiblePosition(): Boolean = false
|
||||
override fun useRefinedBoundsForTypeVariableInFlexiblePosition(): Boolean = session.languageVersionSettings.supportsFeature(
|
||||
LanguageFeature.JavaTypeParameterDefaultRepresentationWithDNN
|
||||
)
|
||||
|
||||
override fun KotlinTypeMarker.convertToNonRaw(): KotlinTypeMarker {
|
||||
require(this is ConeKotlinType)
|
||||
|
||||
+5
@@ -5,8 +5,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.languageVersionSettings
|
||||
import org.jetbrains.kotlin.fir.renderWithType
|
||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||
import org.jetbrains.kotlin.fir.resolve.inference.ConeTypeParameterBasedTypeVariable
|
||||
@@ -166,6 +168,9 @@ internal object CreateFreshTypeVariableSubstitutorStage : ResolutionStage() {
|
||||
}
|
||||
|
||||
private fun FirTypeParameterRef.shouldBeFlexible(context: ConeTypeContext): Boolean {
|
||||
if (context.session.languageVersionSettings.supportsFeature(LanguageFeature.JavaTypeParameterDefaultRepresentationWithDNN)) {
|
||||
return false
|
||||
}
|
||||
return symbol.resolvedBounds.any {
|
||||
val type = it.coneType
|
||||
type is ConeFlexibleType || with(context) {
|
||||
|
||||
Reference in New Issue
Block a user