Skip to content

Commit 020f29a

Browse files
committed
Add visibility tests
1 parent 764c139 commit 020f29a

File tree

2 files changed

+178
-0
lines changed

2 files changed

+178
-0
lines changed

java/ql/test/kotlin/library-tests/parameter-defaults/PrintAst.expected

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,3 +996,172 @@ test.kt:
996996
# 1| 6: [NullLiteral] null
997997
# 1| 7: [IntegerLiteral] 3
998998
# 1| 8: [NullLiteral] null
999+
# 156| 14: [Class] VisibilityTests
1000+
# 156| 1: [Constructor] VisibilityTests
1001+
# 156| 5: [BlockStmt] { ... }
1002+
# 156| 0: [SuperConstructorInvocationStmt] super(...)
1003+
# 156| 1: [BlockStmt] { ... }
1004+
# 158| 2: [Method] f
1005+
# 158| 3: [TypeAccess] int
1006+
#-----| 4: (Parameters)
1007+
# 158| 0: [Parameter] x
1008+
# 158| 0: [TypeAccess] int
1009+
# 158| 1: [Parameter] y
1010+
# 158| 0: [TypeAccess] int
1011+
# 158| 5: [BlockStmt] { ... }
1012+
# 158| 0: [ReturnStmt] return ...
1013+
# 158| 0: [AddExpr] ... + ...
1014+
# 158| 0: [VarAccess] x
1015+
# 158| 1: [VarAccess] y
1016+
# 158| 3: [Method] f$default
1017+
# 158| 3: [TypeAccess] int
1018+
#-----| 4: (Parameters)
1019+
# 158| 0: [Parameter] p0
1020+
# 158| 0: [TypeAccess] VisibilityTests
1021+
# 158| 1: [Parameter] p1
1022+
# 158| 0: [TypeAccess] int
1023+
# 158| 2: [Parameter] p2
1024+
# 158| 0: [TypeAccess] int
1025+
# 158| 3: [Parameter] p3
1026+
# 158| 0: [TypeAccess] int
1027+
# 158| 4: [Parameter] p4
1028+
# 158| 0: [TypeAccess] Object
1029+
# 158| 5: [BlockStmt] { ... }
1030+
# 158| 0: [IfStmt] if (...)
1031+
# 158| 0: [EQExpr] ... == ...
1032+
# 158| 0: [AndBitwiseExpr] ... & ...
1033+
# 158| 0: [IntegerLiteral] 2
1034+
# 158| 1: [VarAccess] p3
1035+
# 158| 1: [IntegerLiteral] 0
1036+
# 158| 1: [ExprStmt] <Expr>;
1037+
# 158| 0: [AssignExpr] ...=...
1038+
# 158| 0: [VarAccess] p2
1039+
# 158| 1: [IntegerLiteral] 0
1040+
# 158| 1: [ReturnStmt] return ...
1041+
# 158| 0: [MethodAccess] f(...)
1042+
# 158| -1: [VarAccess] p0
1043+
# 158| 0: [VarAccess] p1
1044+
# 158| 1: [VarAccess] p2
1045+
# 159| 4: [Method] g$main
1046+
# 159| 3: [TypeAccess] int
1047+
#-----| 4: (Parameters)
1048+
# 159| 0: [Parameter] x
1049+
# 159| 0: [TypeAccess] int
1050+
# 159| 1: [Parameter] y
1051+
# 159| 0: [TypeAccess] int
1052+
# 159| 5: [BlockStmt] { ... }
1053+
# 159| 0: [ReturnStmt] return ...
1054+
# 159| 0: [AddExpr] ... + ...
1055+
# 159| 0: [VarAccess] x
1056+
# 159| 1: [VarAccess] y
1057+
# 159| 5: [Method] g$main$default
1058+
# 159| 3: [TypeAccess] int
1059+
#-----| 4: (Parameters)
1060+
# 159| 0: [Parameter] p0
1061+
# 159| 0: [TypeAccess] VisibilityTests
1062+
# 159| 1: [Parameter] p1
1063+
# 159| 0: [TypeAccess] int
1064+
# 159| 2: [Parameter] p2
1065+
# 159| 0: [TypeAccess] int
1066+
# 159| 3: [Parameter] p3
1067+
# 159| 0: [TypeAccess] int
1068+
# 159| 4: [Parameter] p4
1069+
# 159| 0: [TypeAccess] Object
1070+
# 159| 5: [BlockStmt] { ... }
1071+
# 159| 0: [IfStmt] if (...)
1072+
# 159| 0: [EQExpr] ... == ...
1073+
# 159| 0: [AndBitwiseExpr] ... & ...
1074+
# 159| 0: [IntegerLiteral] 2
1075+
# 159| 1: [VarAccess] p3
1076+
# 159| 1: [IntegerLiteral] 0
1077+
# 159| 1: [ExprStmt] <Expr>;
1078+
# 159| 0: [AssignExpr] ...=...
1079+
# 159| 0: [VarAccess] p2
1080+
# 159| 1: [IntegerLiteral] 0
1081+
# 159| 1: [ReturnStmt] return ...
1082+
# 159| 0: [MethodAccess] g$main(...)
1083+
# 159| -1: [VarAccess] p0
1084+
# 159| 0: [VarAccess] p1
1085+
# 159| 1: [VarAccess] p2
1086+
# 160| 6: [Method] h
1087+
# 160| 3: [TypeAccess] int
1088+
#-----| 4: (Parameters)
1089+
# 160| 0: [Parameter] x
1090+
# 160| 0: [TypeAccess] int
1091+
# 160| 1: [Parameter] y
1092+
# 160| 0: [TypeAccess] int
1093+
# 160| 5: [BlockStmt] { ... }
1094+
# 160| 0: [ReturnStmt] return ...
1095+
# 160| 0: [AddExpr] ... + ...
1096+
# 160| 0: [VarAccess] x
1097+
# 160| 1: [VarAccess] y
1098+
# 160| 7: [Method] h$default
1099+
# 160| 3: [TypeAccess] int
1100+
#-----| 4: (Parameters)
1101+
# 160| 0: [Parameter] p0
1102+
# 160| 0: [TypeAccess] VisibilityTests
1103+
# 160| 1: [Parameter] p1
1104+
# 160| 0: [TypeAccess] int
1105+
# 160| 2: [Parameter] p2
1106+
# 160| 0: [TypeAccess] int
1107+
# 160| 3: [Parameter] p3
1108+
# 160| 0: [TypeAccess] int
1109+
# 160| 4: [Parameter] p4
1110+
# 160| 0: [TypeAccess] Object
1111+
# 160| 5: [BlockStmt] { ... }
1112+
# 160| 0: [IfStmt] if (...)
1113+
# 160| 0: [EQExpr] ... == ...
1114+
# 160| 0: [AndBitwiseExpr] ... & ...
1115+
# 160| 0: [IntegerLiteral] 2
1116+
# 160| 1: [VarAccess] p3
1117+
# 160| 1: [IntegerLiteral] 0
1118+
# 160| 1: [ExprStmt] <Expr>;
1119+
# 160| 0: [AssignExpr] ...=...
1120+
# 160| 0: [VarAccess] p2
1121+
# 160| 1: [IntegerLiteral] 0
1122+
# 160| 1: [ReturnStmt] return ...
1123+
# 160| 0: [MethodAccess] h(...)
1124+
# 160| -1: [VarAccess] p0
1125+
# 160| 0: [VarAccess] p1
1126+
# 160| 1: [VarAccess] p2
1127+
# 161| 8: [Method] i
1128+
# 161| 3: [TypeAccess] int
1129+
#-----| 4: (Parameters)
1130+
# 161| 0: [Parameter] x
1131+
# 161| 0: [TypeAccess] int
1132+
# 161| 1: [Parameter] y
1133+
# 161| 0: [TypeAccess] int
1134+
# 161| 5: [BlockStmt] { ... }
1135+
# 161| 0: [ReturnStmt] return ...
1136+
# 161| 0: [AddExpr] ... + ...
1137+
# 161| 0: [VarAccess] x
1138+
# 161| 1: [VarAccess] y
1139+
# 161| 9: [Method] i$default
1140+
# 161| 3: [TypeAccess] int
1141+
#-----| 4: (Parameters)
1142+
# 161| 0: [Parameter] p0
1143+
# 161| 0: [TypeAccess] VisibilityTests
1144+
# 161| 1: [Parameter] p1
1145+
# 161| 0: [TypeAccess] int
1146+
# 161| 2: [Parameter] p2
1147+
# 161| 0: [TypeAccess] int
1148+
# 161| 3: [Parameter] p3
1149+
# 161| 0: [TypeAccess] int
1150+
# 161| 4: [Parameter] p4
1151+
# 161| 0: [TypeAccess] Object
1152+
# 161| 5: [BlockStmt] { ... }
1153+
# 161| 0: [IfStmt] if (...)
1154+
# 161| 0: [EQExpr] ... == ...
1155+
# 161| 0: [AndBitwiseExpr] ... & ...
1156+
# 161| 0: [IntegerLiteral] 2
1157+
# 161| 1: [VarAccess] p3
1158+
# 161| 1: [IntegerLiteral] 0
1159+
# 161| 1: [ExprStmt] <Expr>;
1160+
# 161| 0: [AssignExpr] ...=...
1161+
# 161| 0: [VarAccess] p2
1162+
# 161| 1: [IntegerLiteral] 0
1163+
# 161| 1: [ReturnStmt] return ...
1164+
# 161| 0: [MethodAccess] i(...)
1165+
# 161| -1: [VarAccess] p0
1166+
# 161| 0: [VarAccess] p1
1167+
# 161| 1: [VarAccess] p2

java/ql/test/kotlin/library-tests/parameter-defaults/test.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,12 @@ class TestGenericFunction<T> {
152152
}
153153

154154
}
155+
156+
class VisibilityTests {
157+
158+
fun f(x: Int, y: Int = 0) = x + y
159+
internal fun g(x: Int, y: Int = 0) = x + y
160+
protected fun h(x: Int, y: Int = 0) = x + y
161+
private fun i(x: Int, y: Int = 0) = x + y
162+
163+
}

0 commit comments

Comments
 (0)