mirror of
https://github.com/github/codeql.git
synced 2025-12-18 18:10:39 +01:00
Merge pull request #11121 from smowton/smowton/fix/java-wildcard-extraction
Kotlin: fix extraction of Java nested wildcards; wildcards in return types
This commit is contained in:
@@ -963,9 +963,9 @@ open class KotlinUsesExtractor(
|
||||
private fun wildcardAdditionAllowed(v: Variance, t: IrType, addByDefault: Boolean, javaVariance: Variance?) =
|
||||
when {
|
||||
t.hasAnnotation(jvmWildcardAnnotation) -> true
|
||||
!addByDefault -> false
|
||||
// If a Java declaration specifies a variance, introduce it even if it's pointless (e.g. ? extends FinalClass, or ? super Object)
|
||||
javaVariance == v -> true
|
||||
!addByDefault -> false
|
||||
v == Variance.IN_VARIANCE -> !(t.isNullableAny() || t.isAny())
|
||||
v == Variance.OUT_VARIANCE -> extendsAdditionAllowed(t)
|
||||
else -> false
|
||||
@@ -1006,8 +1006,9 @@ open class KotlinUsesExtractor(
|
||||
null
|
||||
} ?: t
|
||||
|
||||
private fun getJavaTypeArgument(jt: JavaType, idx: Int) =
|
||||
private fun getJavaTypeArgument(jt: JavaType, idx: Int): JavaType? =
|
||||
when(jt) {
|
||||
is JavaWildcardType -> jt.bound?.let { getJavaTypeArgument(it, idx) }
|
||||
is JavaClassifierType -> jt.typeArguments.getOrNull(idx)
|
||||
is JavaArrayType -> if (idx == 0) jt.componentType else null
|
||||
else -> null
|
||||
|
||||
Reference in New Issue
Block a user