mirror of
https://github.com/github/codeql.git
synced 2025-12-27 14:16:34 +01:00
Merge pull request #4627 from tamasvajk/feature/csharp9-covariant-return
C#: Add test for covariant return types
This commit is contained in:
9
csharp/ql/test/library-tests/csharp9/CovariantReturn.cs
Normal file
9
csharp/ql/test/library-tests/csharp9/CovariantReturn.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
class A
|
||||
{
|
||||
public virtual A M1() { throw null; }
|
||||
}
|
||||
|
||||
class B : A
|
||||
{
|
||||
public override B M1() { throw null; }
|
||||
}
|
||||
@@ -117,6 +117,21 @@ BinaryPattern.cs:
|
||||
# 19| 1: [SwitchCaseExpr] ... => ...
|
||||
# 19| 0: [DiscardPatternExpr] _
|
||||
# 19| 2: [StringLiteral] "other"
|
||||
CovariantReturn.cs:
|
||||
# 1| [Class] A
|
||||
# 3| 5: [Method] M1
|
||||
# 3| -1: [TypeMention] A
|
||||
# 3| 4: [BlockStmt] {...}
|
||||
# 3| 0: [ThrowStmt] throw ...;
|
||||
# 3| 0: [NullLiteral] null
|
||||
# 6| [Class] B
|
||||
#-----| 3: (Base types)
|
||||
# 6| 0: [TypeMention] A
|
||||
# 8| 5: [Method] M1
|
||||
# 8| -1: [TypeMention] B
|
||||
# 8| 4: [BlockStmt] {...}
|
||||
# 8| 0: [ThrowStmt] throw ...;
|
||||
# 8| 0: [NullLiteral] null
|
||||
Discard.cs:
|
||||
# 3| [Class] Discard
|
||||
# 5| 5: [Method] M1
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
| A.M1 | A | B.M1 | B |
|
||||
8
csharp/ql/test/library-tests/csharp9/covariantReturn.ql
Normal file
8
csharp/ql/test/library-tests/csharp9/covariantReturn.ql
Normal file
@@ -0,0 +1,8 @@
|
||||
import csharp
|
||||
|
||||
from Method m, Method overrider
|
||||
where
|
||||
m.getAnOverrider() = overrider and
|
||||
m.getFile().getStem() = "CovariantReturn"
|
||||
select m.getQualifiedName(), m.getReturnType().toString(), overrider.getQualifiedName(),
|
||||
overrider.getReturnType().toString()
|
||||
Reference in New Issue
Block a user