Report unsupported errors on annotations on underscored type arguments
This commit is contained in:
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.isUnderscoreNamed
|
||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil
|
||||
import org.jetbrains.kotlin.resolve.scopes.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.expressions.*
|
||||
import org.jetbrains.kotlin.types.model.TypeSystemInferenceExtensionContext
|
||||
@@ -689,9 +690,14 @@ class PSICallResolver(
|
||||
val typeReference = projection.typeReference ?: return@map TypeArgumentPlaceholder
|
||||
|
||||
if (typeReference.isPlaceholder) {
|
||||
ForceResolveUtil.forceResolveAllContents(
|
||||
typeResolver.resolveTypeAnnotations(context.trace, context.scope, typeReference)
|
||||
)
|
||||
val resolvedAnnotations = typeResolver.resolveTypeAnnotations(context.trace, context.scope, typeReference)
|
||||
.apply(ForceResolveUtil::forceResolveAllContents)
|
||||
|
||||
for (annotation in resolvedAnnotations) {
|
||||
val annotationElement = annotation.source.getPsi() ?: continue
|
||||
context.trace.report(Errors.UNSUPPORTED.on(annotationElement, "annotations on an underscored type argument"))
|
||||
}
|
||||
|
||||
return@map TypeArgumentPlaceholder
|
||||
}
|
||||
|
||||
|
||||
+15
-1
@@ -4,10 +4,24 @@
|
||||
|
||||
fun <K, T> foo(x: (K) -> T): Pair<K, T> = (1 as K) to (1f as T)
|
||||
|
||||
@Repeatable
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Anno
|
||||
|
||||
@Repeatable
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Anno2
|
||||
|
||||
@Repeatable
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Anno3(val x: String)
|
||||
|
||||
fun box(): String {
|
||||
val x = foo<@Anno Int, @Anno _> { it.toFloat() }
|
||||
val x = foo<@Anno Int, <!UNSUPPORTED("annotations on an underscored type argument")!>@Anno<!> _> { it.toFloat() }
|
||||
val y: Pair<Int, Float> = foo<@[<!UNSUPPORTED!>Anno<!> <!UNSUPPORTED!>Anno2<!>] _, <!UNSUPPORTED!>@Anno<!> _> { it.toFloat() }
|
||||
val z1: Pair<Int, Float> = foo<<!UNSUPPORTED!>@Anno<!> <!UNSUPPORTED!>@Anno2<!> /**/ _, @[/**/ <!UNSUPPORTED!>Anno<!> /**/ ] _> { it.toFloat() }
|
||||
val z2: Pair<Int, Float> = foo<<!UNSUPPORTED!>@Anno3("")<!> /**/ _, @[/**/ <!UNSUPPORTED!>Anno<!> /**/ <!UNSUPPORTED!>Anno3("")<!> /**/] _,> { it.toFloat() }
|
||||
|
||||
val z3: Pair<@Anno3("") <!UNRESOLVED_REFERENCE!>_<!>, Float> = 1 to 1f
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+17
-1
@@ -3,9 +3,25 @@ package
|
||||
public fun box(): kotlin.String
|
||||
public fun </*0*/ K, /*1*/ T> foo(/*0*/ x: (K) -> T): kotlin.Pair<K, T>
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Anno : kotlin.Annotation {
|
||||
@kotlin.annotation.Repeatable @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Anno : kotlin.Annotation {
|
||||
public constructor Anno()
|
||||
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
|
||||
}
|
||||
|
||||
@kotlin.annotation.Repeatable @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Anno2 : kotlin.Annotation {
|
||||
public constructor Anno2()
|
||||
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
|
||||
}
|
||||
|
||||
@kotlin.annotation.Repeatable @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Anno3 : kotlin.Annotation {
|
||||
public constructor Anno3(/*0*/ x: kotlin.String)
|
||||
public final val x: kotlin.String
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user