Filter annotations while substituting compound type
This commit is contained in:
+19
-2
@@ -1,13 +1,30 @@
|
|||||||
|
//!DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||||
fun <R> Iterable<*>.filterIsInstance1(): List<@kotlin.internal.NoInfer R> = throw Exception()
|
fun <R> Iterable<*>.filterIsInstance1(): List<@kotlin.internal.NoInfer R> = throw Exception()
|
||||||
|
|
||||||
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||||
|
fun <R> List<*>.filterIsInstance2(): @kotlin.internal.NoInfer List<R> = throw Exception()
|
||||||
|
|
||||||
fun test(list: List<Int>) {
|
fun test(list: List<Int>) {
|
||||||
list.filterIsInstance1<Int>().map { it * 2}
|
list.filterIsInstance1<Int>().map { it * 2 }
|
||||||
|
list.filterIsInstance2<Int>().filter { it > 10 }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||||
fun <R> foo(t: R): List<@kotlin.internal.NoInfer R> = throw Exception("$t")
|
fun <R> foo(t: R): List<@kotlin.internal.NoInfer R> = throw Exception("$t")
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
foo(1).map { it * 2}
|
foo(1).map { it * 2 }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||||
|
fun <R> List<R>.foo(): @kotlin.internal.NoInfer R = throw Exception()
|
||||||
|
|
||||||
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||||
|
fun <R> bar(r: R, f: Function1<@kotlin.internal.NoInfer R, Unit>): Nothing = throw Exception()
|
||||||
|
|
||||||
|
fun test1() {
|
||||||
|
listOf("").foo().length
|
||||||
|
bar(1) { x -> x + 1 }
|
||||||
}
|
}
|
||||||
+4
@@ -1,6 +1,10 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
|
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun </*0*/ R> bar(/*0*/ r: R, /*1*/ f: (R) -> kotlin.Unit): kotlin.Nothing
|
||||||
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun </*0*/ R> foo(/*0*/ t: R): kotlin.List<R>
|
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun </*0*/ R> foo(/*0*/ t: R): kotlin.List<R>
|
||||||
public fun test(): kotlin.Unit
|
public fun test(): kotlin.Unit
|
||||||
public fun test(/*0*/ list: kotlin.List<kotlin.Int>): kotlin.Unit
|
public fun test(/*0*/ list: kotlin.List<kotlin.Int>): kotlin.Unit
|
||||||
|
public fun test1(): kotlin.Unit
|
||||||
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun </*0*/ R> kotlin.Iterable<*>.filterIsInstance1(): kotlin.List<R>
|
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun </*0*/ R> kotlin.Iterable<*>.filterIsInstance1(): kotlin.List<R>
|
||||||
|
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun </*0*/ R> kotlin.List<*>.filterIsInstance2(): kotlin.List<R>
|
||||||
|
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun </*0*/ R> kotlin.List<R>.foo(): R
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ public class TypeSubstitutor {
|
|||||||
return containedOrCapturedTypeParameters.contains(key.getConstructor()) ? substitution.get(key) : null;
|
return containedOrCapturedTypeParameters.contains(key.getConstructor()) ? substitution.get(key) : null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
KotlinType substitutedType = KotlinTypeImpl.create(type.getAnnotations(), // Old annotations. This is questionable
|
KotlinType substitutedType = KotlinTypeImpl.create(substitution.filterAnnotations(type.getAnnotations()), // Old annotations. This is questionable
|
||||||
type.getConstructor(), // The same constructor
|
type.getConstructor(), // The same constructor
|
||||||
type.isMarkedNullable(), // Same nullability
|
type.isMarkedNullable(), // Same nullability
|
||||||
substitutedArguments,
|
substitutedArguments,
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ fun TypeProjection.substitute(doSubstitute: (KotlinType) -> KotlinType): TypePro
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun KotlinType.replaceAnnotations(newAnnotations: Annotations): KotlinType {
|
fun KotlinType.replaceAnnotations(newAnnotations: Annotations): KotlinType {
|
||||||
if (newAnnotations.isEmpty()) return this
|
if (annotations.isEmpty() && newAnnotations.isEmpty()) return this
|
||||||
return object : DelegatingType() {
|
return object : DelegatingType() {
|
||||||
override fun getDelegate() = this@replaceAnnotations
|
override fun getDelegate() = this@replaceAnnotations
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user