mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
Extract type parameter bounds
This commit is contained in:
committed by
Ian Lynagh
parent
ec5bc8dad5
commit
8bb23651ae
@@ -151,7 +151,13 @@ open class KotlinFileExtractor(
|
||||
val locId = tw.getLocation(tp)
|
||||
tw.writeHasLocation(id, locId)
|
||||
|
||||
// todo: add type bounds
|
||||
tp.superTypes.forEachIndexed { boundIdx, bound ->
|
||||
if(!(bound.isAny() || bound.isNullableAny())) {
|
||||
tw.getLabelFor<DbTypebound>("@\"bound;$boundIdx;{$id}\"") {
|
||||
tw.writeTypeBounds(it, useType(bound).javaResult.id as Label<out DbReftype>, boundIdx, id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
classTVs
|
||||
| test.kt:1:12:1:21 | T | test.kt:1:1:5:1 | Test | Number |
|
||||
| test.kt:1:24:1:28 | S | test.kt:1:1:5:1 | Test | T |
|
||||
| test.kt:1:31:1:31 | R | test.kt:1:1:5:1 | Test | Object |
|
||||
| test.kt:7:22:7:22 | P | test.kt:7:1:7:67 | MultipleBounds | List<String> |
|
||||
| test.kt:7:22:7:22 | P | test.kt:7:1:7:67 | MultipleBounds | Set<String> |
|
||||
functionTVs
|
||||
| test.kt:3:8:3:17 | Q | test.kt:3:3:3:26 | f | Number |
|
||||
@@ -0,0 +1,7 @@
|
||||
class Test<T : Number, S : T, R> {
|
||||
|
||||
fun <Q : Number> f() { }
|
||||
|
||||
}
|
||||
|
||||
class MultipleBounds<P> where P : List<String>, P : Set<String> { }
|
||||
@@ -0,0 +1,9 @@
|
||||
import java
|
||||
|
||||
query predicate classTVs(TypeVariable tv, GenericType declType, string bound) {
|
||||
tv.getGenericType() = declType and tv.getUpperBoundType().toString() = bound and declType.fromSource()
|
||||
}
|
||||
|
||||
query predicate functionTVs(TypeVariable tv, GenericCallable callable, string bound) {
|
||||
tv.getGenericCallable() = callable and tv.getUpperBoundType().toString() = bound and callable.fromSource()
|
||||
}
|
||||
Reference in New Issue
Block a user