[NI] Fix loosing type annotations on extension functions
#KT-32138 fixed
This commit is contained in:
+10
@@ -11030,6 +11030,16 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32189returnTypeWithTypealiasSubtitution.kt")
|
||||||
|
public void testKt32189returnTypeWithTypealiasSubtitution() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/substitutions/kt32189returnTypeWithTypealiasSubtitution.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32189returnTypeWithTypealiasSubtitutionOldInference.kt")
|
||||||
|
public void testKt32189returnTypeWithTypealiasSubtitutionOldInference() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/substitutions/kt32189returnTypeWithTypealiasSubtitutionOldInference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt6081SubstituteIntoClassCorrectly.kt")
|
@TestMetadata("kt6081SubstituteIntoClassCorrectly.kt")
|
||||||
public void testKt6081SubstituteIntoClassCorrectly() throws Exception {
|
public void testKt6081SubstituteIntoClassCorrectly() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/substitutions/kt6081SubstituteIntoClassCorrectly.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/substitutions/kt6081SubstituteIntoClassCorrectly.kt");
|
||||||
|
|||||||
+5
-3
@@ -35,9 +35,11 @@ object JvmDeclarationReturnTypeSanitizer : DeclarationReturnTypeSanitizer {
|
|||||||
if (languageVersionSettings.supportsFeature(LanguageFeature.StrictJavaNullabilityAssertions)) {
|
if (languageVersionSettings.supportsFeature(LanguageFeature.StrictJavaNullabilityAssertions)) {
|
||||||
// NB can't check for presence of EnhancedNullability here,
|
// NB can't check for presence of EnhancedNullability here,
|
||||||
// because it will also cause recursion in declaration type resolution.
|
// because it will also cause recursion in declaration type resolution.
|
||||||
inferred.replaceAnnotations(FilteredAnnotations(inferred.annotations) {
|
inferred.replaceAnnotations(
|
||||||
it != JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION
|
FilteredAnnotations(inferred.annotations, languageVersionSettings.supportsFeature(LanguageFeature.NewInference)) {
|
||||||
})
|
it != JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
else inferred
|
else inferred
|
||||||
}
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
class B {
|
||||||
|
class Builder
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias ApplyRestrictions = B.Builder.() -> B.Builder
|
||||||
|
|
||||||
|
fun applyRestrictions1(): ApplyRestrictions = TODO()
|
||||||
|
fun applyRestrictions2() = applyRestrictions1()
|
||||||
|
fun <K> applyRestrictions3(e: K) = applyRestrictions1()
|
||||||
|
|
||||||
|
fun buildB() {
|
||||||
|
val a1 = applyRestrictions1()
|
||||||
|
val a2 = applyRestrictions2()
|
||||||
|
val a3 = applyRestrictions3("foo")
|
||||||
|
|
||||||
|
B.Builder().a1()
|
||||||
|
B.Builder().a2()
|
||||||
|
B.Builder().a3()
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun applyRestrictions1(): ApplyRestrictions /* = B.Builder.() -> B.Builder */
|
||||||
|
public fun applyRestrictions2(): ApplyRestrictions /* = B.Builder.() -> B.Builder */
|
||||||
|
public fun </*0*/ K> applyRestrictions3(/*0*/ e: K): ApplyRestrictions /* = B.Builder.() -> B.Builder */
|
||||||
|
public fun buildB(): kotlin.Unit
|
||||||
|
|
||||||
|
public final class B {
|
||||||
|
public constructor B()
|
||||||
|
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 final class Builder {
|
||||||
|
public constructor Builder()
|
||||||
|
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 typealias ApplyRestrictions = B.Builder.() -> B.Builder
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// !LANGUAGE: -NewInference
|
||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
class B {
|
||||||
|
class Builder
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias ApplyRestrictions = B.Builder.() -> B.Builder
|
||||||
|
|
||||||
|
fun applyRestrictions1(): ApplyRestrictions = TODO()
|
||||||
|
fun applyRestrictions2() = applyRestrictions1()
|
||||||
|
fun <K> applyRestrictions3(e: K) = applyRestrictions1()
|
||||||
|
|
||||||
|
fun buildB() {
|
||||||
|
val a1 = applyRestrictions1()
|
||||||
|
val a2 = applyRestrictions2()
|
||||||
|
val a3 = applyRestrictions3("foo")
|
||||||
|
|
||||||
|
B.Builder().a1()
|
||||||
|
B.Builder().a2()
|
||||||
|
B.Builder().<!UNRESOLVED_REFERENCE!>a3<!>()
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun applyRestrictions1(): ApplyRestrictions /* = B.Builder.() -> B.Builder */
|
||||||
|
public fun applyRestrictions2(): ApplyRestrictions /* = B.Builder.() -> B.Builder */
|
||||||
|
public fun </*0*/ K> applyRestrictions3(/*0*/ e: K): ApplyRestrictions /* = B.Builder.() -> B.Builder */
|
||||||
|
public fun buildB(): kotlin.Unit
|
||||||
|
|
||||||
|
public final class B {
|
||||||
|
public constructor B()
|
||||||
|
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 final class Builder {
|
||||||
|
public constructor Builder()
|
||||||
|
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 typealias ApplyRestrictions = B.Builder.() -> B.Builder
|
||||||
@@ -11037,6 +11037,16 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32189returnTypeWithTypealiasSubtitution.kt")
|
||||||
|
public void testKt32189returnTypeWithTypealiasSubtitution() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/substitutions/kt32189returnTypeWithTypealiasSubtitution.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32189returnTypeWithTypealiasSubtitutionOldInference.kt")
|
||||||
|
public void testKt32189returnTypeWithTypealiasSubtitutionOldInference() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/substitutions/kt32189returnTypeWithTypealiasSubtitutionOldInference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt6081SubstituteIntoClassCorrectly.kt")
|
@TestMetadata("kt6081SubstituteIntoClassCorrectly.kt")
|
||||||
public void testKt6081SubstituteIntoClassCorrectly() throws Exception {
|
public void testKt6081SubstituteIntoClassCorrectly() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/substitutions/kt6081SubstituteIntoClassCorrectly.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/substitutions/kt6081SubstituteIntoClassCorrectly.kt");
|
||||||
|
|||||||
Generated
+10
@@ -11032,6 +11032,16 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32189returnTypeWithTypealiasSubtitution.kt")
|
||||||
|
public void testKt32189returnTypeWithTypealiasSubtitution() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/substitutions/kt32189returnTypeWithTypealiasSubtitution.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32189returnTypeWithTypealiasSubtitutionOldInference.kt")
|
||||||
|
public void testKt32189returnTypeWithTypealiasSubtitutionOldInference() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/substitutions/kt32189returnTypeWithTypealiasSubtitutionOldInference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt6081SubstituteIntoClassCorrectly.kt")
|
@TestMetadata("kt6081SubstituteIntoClassCorrectly.kt")
|
||||||
public void testKt6081SubstituteIntoClassCorrectly() throws Exception {
|
public void testKt6081SubstituteIntoClassCorrectly() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/substitutions/kt6081SubstituteIntoClassCorrectly.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/substitutions/kt6081SubstituteIntoClassCorrectly.kt");
|
||||||
|
|||||||
@@ -51,9 +51,12 @@ interface Annotations : Iterable<AnnotationDescriptor> {
|
|||||||
|
|
||||||
class FilteredAnnotations(
|
class FilteredAnnotations(
|
||||||
private val delegate: Annotations,
|
private val delegate: Annotations,
|
||||||
|
private val isDefinitelyNewInference: Boolean,
|
||||||
private val fqNameFilter: (FqName) -> Boolean
|
private val fqNameFilter: (FqName) -> Boolean
|
||||||
) : Annotations {
|
) : Annotations {
|
||||||
|
|
||||||
|
constructor(delegate: Annotations, fqNameFilter: (FqName) -> Boolean) : this(delegate, false, fqNameFilter)
|
||||||
|
|
||||||
override fun hasAnnotation(fqName: FqName) =
|
override fun hasAnnotation(fqName: FqName) =
|
||||||
if (fqNameFilter(fqName)) delegate.hasAnnotation(fqName)
|
if (fqNameFilter(fqName)) delegate.hasAnnotation(fqName)
|
||||||
else false
|
else false
|
||||||
@@ -64,7 +67,11 @@ class FilteredAnnotations(
|
|||||||
|
|
||||||
override fun iterator() = delegate.filter(this::shouldBeReturned).iterator()
|
override fun iterator() = delegate.filter(this::shouldBeReturned).iterator()
|
||||||
|
|
||||||
override fun isEmpty() = delegate.any(this::shouldBeReturned)
|
override fun isEmpty(): Boolean {
|
||||||
|
val condition = delegate.any(this::shouldBeReturned)
|
||||||
|
// fixing KT-32189 && KT-32138 for the new inference only
|
||||||
|
return if (isDefinitelyNewInference) !condition else condition
|
||||||
|
}
|
||||||
|
|
||||||
private fun shouldBeReturned(annotation: AnnotationDescriptor): Boolean =
|
private fun shouldBeReturned(annotation: AnnotationDescriptor): Boolean =
|
||||||
annotation.fqName.let { fqName ->
|
annotation.fqName.let { fqName ->
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
class B {
|
||||||
|
class Builder
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias ApplyRestrictions = B.Builder.() -> B.Builder
|
||||||
|
|
||||||
|
fun applyRestrictions1(): ApplyRestrictions = { this }
|
||||||
|
fun applyRestrictions2() = applyRestrictions1()
|
||||||
|
fun <K> applyRestrictions3(<warning descr="[UNUSED_PARAMETER] Parameter 'e' is never used">e</warning>: K) = applyRestrictions1()
|
||||||
|
|
||||||
|
fun buildB() {
|
||||||
|
val a1 = applyRestrictions1()
|
||||||
|
val a2 = applyRestrictions2()
|
||||||
|
val a3 = applyRestrictions3("foo")
|
||||||
|
|
||||||
|
B.Builder().a1()
|
||||||
|
B.Builder().a2()
|
||||||
|
B.Builder().a3()
|
||||||
|
}
|
||||||
@@ -155,6 +155,11 @@ public class PsiCheckerTestGenerated extends AbstractPsiCheckerTest {
|
|||||||
runTest("idea/testData/checker/JvmStaticUsagesRuntime.kt");
|
runTest("idea/testData/checker/JvmStaticUsagesRuntime.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32189returnTypeWithTypealiasSubtitution.kt")
|
||||||
|
public void testKt32189returnTypeWithTypealiasSubtitution() throws Exception {
|
||||||
|
runTest("idea/testData/checker/kt32189returnTypeWithTypealiasSubtitution.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("LocalObjects.kt")
|
@TestMetadata("LocalObjects.kt")
|
||||||
public void testLocalObjects() throws Exception {
|
public void testLocalObjects() throws Exception {
|
||||||
runTest("idea/testData/checker/LocalObjects.kt");
|
runTest("idea/testData/checker/LocalObjects.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user