mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Add tests for generic methods
This commit is contained in:
committed by
Ian Lynagh
parent
67d2c52e86
commit
5c77131637
@@ -0,0 +1,10 @@
|
||||
public class ClassWithParams<T> {
|
||||
|
||||
fun noTypeParams() { }
|
||||
|
||||
fun <S> instanceHasTypeParam(s : S?) { }
|
||||
|
||||
fun <S> instanceHasTypeParamUsesClassTypeParam(s : S?, t: T?) { }
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
public class ClassWithoutParams {
|
||||
|
||||
fun noTypeParams() { }
|
||||
|
||||
fun <T> hasTypeParams(t : T?) { }
|
||||
|
||||
}
|
||||
17
java/ql/test/kotlin/library-tests/generic-methods/kttest.kt
Normal file
17
java/ql/test/kotlin/library-tests/generic-methods/kttest.kt
Normal file
@@ -0,0 +1,17 @@
|
||||
fun test() {
|
||||
|
||||
val cwp = ClassWithoutParams()
|
||||
cwp.noTypeParams();
|
||||
cwp.hasTypeParams<ClassWithoutParams>(null)
|
||||
|
||||
val specialised = ClassWithParams<String>()
|
||||
specialised.noTypeParams()
|
||||
specialised.instanceHasTypeParam<ClassWithoutParams>(null)
|
||||
specialised.instanceHasTypeParamUsesClassTypeParam<ClassWithoutParams>(null, null)
|
||||
|
||||
val wildcard : ClassWithParams<out Any> = ClassWithParams<Any>()
|
||||
wildcard.noTypeParams()
|
||||
wildcard.instanceHasTypeParam<ClassWithoutParams>(null)
|
||||
wildcard.instanceHasTypeParamUsesClassTypeParam<ClassWithoutParams>(null, null)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
| kttest.kt:5:5:5:7 | cwp | ClassWithoutParams.kt:5:3:5:35 | hasTypeParams | hasTypeParams(java.lang.Object) | T | ClassWithoutParams.kt:1:1:7:1 | ClassWithoutParams |
|
||||
| kttest.kt:9:5:9:15 | specialised | ClassWithParams.kt:5:3:5:42 | instanceHasTypeParam | instanceHasTypeParam(java.lang.Object) | S | ClassWithParams.kt:1:1:9:1 | ClassWithParams<String> |
|
||||
| kttest.kt:10:5:10:15 | specialised | ClassWithParams.kt:7:3:7:67 | instanceHasTypeParamUsesClassTypeParam | instanceHasTypeParamUsesClassTypeParam(java.lang.Object,java.lang.String) | S | ClassWithParams.kt:1:1:9:1 | ClassWithParams<String> |
|
||||
| kttest.kt:10:5:10:15 | specialised | ClassWithParams.kt:7:3:7:67 | instanceHasTypeParamUsesClassTypeParam | instanceHasTypeParamUsesClassTypeParam(java.lang.Object,java.lang.String) | String | ClassWithParams.kt:1:1:9:1 | ClassWithParams<String> |
|
||||
| kttest.kt:14:5:14:12 | wildcard | ClassWithParams.kt:5:3:5:42 | instanceHasTypeParam | instanceHasTypeParam(java.lang.Object) | S | ClassWithParams.kt:1:1:9:1 | ClassWithParams<? extends Object> |
|
||||
| kttest.kt:15:5:15:12 | wildcard | ClassWithParams.kt:7:3:7:67 | instanceHasTypeParamUsesClassTypeParam | instanceHasTypeParamUsesClassTypeParam(java.lang.Object,java.lang.Void) | S | ClassWithParams.kt:1:1:9:1 | ClassWithParams<? extends Object> |
|
||||
| kttest.kt:15:5:15:12 | wildcard | ClassWithParams.kt:7:3:7:67 | instanceHasTypeParamUsesClassTypeParam | instanceHasTypeParamUsesClassTypeParam(java.lang.Object,java.lang.Void) | Void | ClassWithParams.kt:1:1:9:1 | ClassWithParams<? extends Object> |
|
||||
@@ -0,0 +1,4 @@
|
||||
import java
|
||||
|
||||
from MethodAccess ma
|
||||
select ma.getQualifier(), ma.getCallee(), ma.getCallee().getSignature(), ma.getCallee().getAParamType().toString(), ma.getCallee().getDeclaringType()
|
||||
Reference in New Issue
Block a user