Change extension receiver this access to be a parameter access

This commit is contained in:
Tamas Vajk
2022-03-16 15:41:19 +01:00
committed by Ian Lynagh
parent 21f6867cd4
commit b26044b327
9 changed files with 67 additions and 31 deletions

View File

@@ -25,7 +25,7 @@ delegatedProperties.kt:
# 87| -2: [TypeAccess] Integer
# 87| -1: [TypeAccess] PropertyReferenceDelegatesKt
# 87| 0: [VarAccess] extDelegated$delegate
# 1| 1: [ThisAccess] this
# 1| 1: [ExtensionReceiverAccess] this
# 87| 2: [PropertyRefExpr] ...::...
# 87| -4: [AnonymousClass] new KMutableProperty1<MyClass,Integer>(...) { ... }
# 87| 1: [Constructor]
@@ -60,7 +60,7 @@ delegatedProperties.kt:
# 87| -2: [TypeAccess] Integer
# 87| -1: [TypeAccess] PropertyReferenceDelegatesKt
# 87| 0: [VarAccess] extDelegated$delegate
# 1| 1: [ThisAccess] this
# 1| 1: [ExtensionReceiverAccess] this
# 87| 2: [PropertyRefExpr] ...::...
# 87| -4: [AnonymousClass] new KMutableProperty1<MyClass,Integer>(...) { ... }
# 87| 1: [Constructor]
@@ -2800,7 +2800,7 @@ funcExprs.kt:
# 26| 5: [BlockStmt] { ... }
# 26| 0: [ReturnStmt] return ...
# 26| 0: [AddExpr] ... + ...
# 26| 0: [ThisAccess] this
# 26| 0: [ExtensionReceiverAccess] this
# 26| 1: [VarAccess] a
# 26| -3: [TypeAccess] Function2<Integer,Integer,Integer>
# 26| 0: [TypeAccess] Integer
@@ -4019,7 +4019,7 @@ samConversion.kt:
# 7| 0: [ReturnStmt] return ...
# 7| 0: [MethodAccess] invoke(...)
# 7| -1: [VarAccess] <fn>
# 7| 0: [VarAccess] <this>
# 7| 0: [ExtensionReceiverAccess] this
# 7| 1: [VarAccess] i
# 7| -3: [TypeAccess] InterfaceFnExt1
# 7| 0: [LambdaExpr] ...->...
@@ -4034,7 +4034,7 @@ samConversion.kt:
# 7| 5: [BlockStmt] { ... }
# 7| 0: [ReturnStmt] return ...
# 7| 0: [ValueEQExpr] ... (value equals) ...
# 7| 0: [ThisAccess] this
# 7| 0: [ExtensionReceiverAccess] this
# 7| 1: [StringLiteral]
# 7| -3: [TypeAccess] Function2<String,Integer,Boolean>
# 7| 0: [TypeAccess] String

View File

@@ -25,8 +25,8 @@
| delegatedProperties.kt:1:9:1:12 | this | delegatedProperties.kt:77:34:77:49 | getDelegatedToTopLevel | ThisAccess |
| delegatedProperties.kt:1:9:1:12 | this | delegatedProperties.kt:77:34:77:49 | setDelegatedToTopLevel | ThisAccess |
| delegatedProperties.kt:1:9:1:12 | this | delegatedProperties.kt:79:18:79:38 | getMax | ThisAccess |
| delegatedProperties.kt:1:9:1:12 | this | delegatedProperties.kt:87:31:87:46 | getExtDelegated | ThisAccess |
| delegatedProperties.kt:1:9:1:12 | this | delegatedProperties.kt:87:31:87:46 | setExtDelegated | ThisAccess |
| delegatedProperties.kt:1:9:1:12 | this | delegatedProperties.kt:87:31:87:46 | getExtDelegated | ExtensionReceiverAccess |
| delegatedProperties.kt:1:9:1:12 | this | delegatedProperties.kt:87:31:87:46 | setExtDelegated | ExtensionReceiverAccess |
| delegatedProperties.kt:6:24:9:9 | ...::... | delegatedProperties.kt:6:24:9:9 | <get-prop1> | PropertyRefExpr |
| delegatedProperties.kt:6:24:9:9 | <get-prop1>(...) | delegatedProperties.kt:6:24:9:9 | get | MethodAccess |
| delegatedProperties.kt:6:24:9:9 | Integer | delegatedProperties.kt:6:24:9:9 | <get-prop1> | TypeAccess |
@@ -1446,7 +1446,7 @@
| funcExprs.kt:26:28:26:44 | Integer | funcExprs.kt:15:1:46:1 | call | TypeAccess |
| funcExprs.kt:26:28:26:44 | Integer | funcExprs.kt:15:1:46:1 | call | TypeAccess |
| funcExprs.kt:26:28:26:44 | Integer | funcExprs.kt:15:1:46:1 | call | TypeAccess |
| funcExprs.kt:26:35:26:38 | this | funcExprs.kt:26:28:26:44 | invoke | ThisAccess |
| funcExprs.kt:26:35:26:38 | this | funcExprs.kt:26:28:26:44 | invoke | ExtensionReceiverAccess |
| funcExprs.kt:26:35:26:42 | ... + ... | funcExprs.kt:26:28:26:44 | invoke | AddExpr |
| funcExprs.kt:26:42:26:42 | a | funcExprs.kt:26:28:26:44 | invoke | VarAccess |
| funcExprs.kt:27:5:27:51 | functionExpression4(...) | funcExprs.kt:15:1:46:1 | call | MethodAccess |
@@ -2154,7 +2154,6 @@
| samConversion.kt:7:13:7:46 | ...=... | samConversion.kt:7:13:7:46 | | AssignExpr |
| samConversion.kt:7:13:7:46 | <fn> | samConversion.kt:7:13:7:46 | | VarAccess |
| samConversion.kt:7:13:7:46 | <fn> | samConversion.kt:27:5:27:35 | ext | VarAccess |
| samConversion.kt:7:13:7:46 | <this> | samConversion.kt:27:5:27:35 | ext | VarAccess |
| samConversion.kt:7:13:7:46 | Boolean | file://:0:0:0:0 | <none> | TypeAccess |
| samConversion.kt:7:13:7:46 | Function2<String,Integer,Boolean> | file://:0:0:0:0 | <none> | TypeAccess |
| samConversion.kt:7:13:7:46 | Integer | file://:0:0:0:0 | <none> | TypeAccess |
@@ -2165,13 +2164,14 @@
| samConversion.kt:7:13:7:46 | invoke(...) | samConversion.kt:27:5:27:35 | ext | MethodAccess |
| samConversion.kt:7:13:7:46 | new (...) | samConversion.kt:1:1:14:1 | main | ClassInstanceExpr |
| samConversion.kt:7:13:7:46 | this | samConversion.kt:7:13:7:46 | | ThisAccess |
| samConversion.kt:7:13:7:46 | this | samConversion.kt:27:5:27:35 | ext | ExtensionReceiverAccess |
| samConversion.kt:7:13:7:46 | this.<fn> | samConversion.kt:7:13:7:46 | | VarAccess |
| samConversion.kt:7:29:7:46 | ...->... | samConversion.kt:1:1:14:1 | main | LambdaExpr |
| samConversion.kt:7:29:7:46 | Boolean | samConversion.kt:1:1:14:1 | main | TypeAccess |
| samConversion.kt:7:29:7:46 | Function2<String,Integer,Boolean> | samConversion.kt:1:1:14:1 | main | TypeAccess |
| samConversion.kt:7:29:7:46 | Integer | samConversion.kt:1:1:14:1 | main | TypeAccess |
| samConversion.kt:7:29:7:46 | String | samConversion.kt:1:1:14:1 | main | TypeAccess |
| samConversion.kt:7:36:7:39 | this | samConversion.kt:7:29:7:46 | invoke | ThisAccess |
| samConversion.kt:7:36:7:39 | this | samConversion.kt:7:29:7:46 | invoke | ExtensionReceiverAccess |
| samConversion.kt:7:36:7:45 | ... (value equals) ... | samConversion.kt:7:29:7:46 | invoke | ValueEQExpr |
| samConversion.kt:7:44:7:45 | | samConversion.kt:7:29:7:46 | invoke | StringLiteral |
| samConversion.kt:9:5:13:6 | x | samConversion.kt:1:1:14:1 | main | LocalVariableDeclExpr |

View File

@@ -7,10 +7,10 @@ reflection.kt:
# 47| 5: [BlockStmt] { ... }
# 47| 0: [ReturnStmt] return ...
# 47| 0: [MethodAccess] get(...)
# 47| -1: [ThisAccess] this
# 47| -1: [ExtensionReceiverAccess] this
# 47| 0: [SubExpr] ... - ...
# 47| 0: [MethodAccess] getLength(...)
# 47| -1: [ThisAccess] this
# 47| -1: [ExtensionReceiverAccess] this
# 47| 1: [IntegerLiteral] 1
# 49| 2: [Method] fn2
# 49| 5: [BlockStmt] { ... }
@@ -69,14 +69,14 @@ reflection.kt:
# 54| 5: [BlockStmt] { ... }
# 54| 0: [ReturnStmt] return ...
# 54| 0: [MethodAccess] toString(...)
# 54| -1: [ThisAccess] this
# 54| -1: [ExtensionReceiverAccess] this
# 56| 4: [ExtensionMethod] ext2
#-----| 4: (Parameters)
# 56| 0: [Parameter] <this>
# 56| 5: [BlockStmt] { ... }
# 56| 0: [ReturnStmt] return ...
# 56| 0: [MethodAccess] toString(...)
# 56| -1: [ThisAccess] this
# 56| -1: [ExtensionReceiverAccess] this
# 94| 5: [Method] fn
#-----| 2: (Generic Parameters)
# 94| 0: [TypeVariable] T

View File

@@ -1,17 +1,19 @@
extensionReceiverAcc
| this.kt:10:42:10:45 | this |
| this.kt:11:42:11:70 | this |
| this.kt:13:53:13:56 | this |
| this.kt:14:46:14:74 | this |
| this.kt:15:53:15:87 | this |
| this.kt:20:42:20:45 | this |
| this.kt:29:38:29:41 | this |
| this.kt:32:38:32:54 | this |
#select
| this.kt:5:29:5:32 | this | file://:0:0:0:0 | <none> |
| this.kt:6:29:6:38 | this | file://:0:0:0:0 | <none> |
| this.kt:7:29:7:38 | Outer.this | this.kt:7:29:7:38 | Outer |
| this.kt:10:42:10:45 | this | file://:0:0:0:0 | <none> |
| this.kt:11:42:11:70 | this | file://:0:0:0:0 | <none> |
| this.kt:13:53:13:56 | this | file://:0:0:0:0 | <none> |
| this.kt:14:46:14:74 | this | file://:0:0:0:0 | <none> |
| this.kt:15:53:15:87 | this | file://:0:0:0:0 | <none> |
| this.kt:20:42:20:45 | this | file://:0:0:0:0 | <none> |
| this.kt:24:34:24:37 | this | file://:0:0:0:0 | <none> |
| this.kt:29:38:29:41 | this | file://:0:0:0:0 | <none> |
| this.kt:30:29:30:38 | Inner.this | this.kt:30:29:30:38 | Inner |
| this.kt:31:29:31:38 | Outer.this | this.kt:31:29:31:38 | Outer |
| this.kt:32:38:32:54 | this | file://:0:0:0:0 | <none> |
| this.kt:37:13:37:22 | Outer.this | this.kt:37:13:37:22 | Outer |
| this.kt:38:13:38:22 | this | file://:0:0:0:0 | <none> |
| this.kt:39:13:39:30 | Outer.this | this.kt:39:13:39:30 | Outer |

View File

@@ -6,6 +6,7 @@ newtype TMaybeElement =
class MaybeElement extends TMaybeElement {
abstract string toString();
abstract Location getLocation();
}
@@ -13,7 +14,9 @@ class YesMaybeElement extends MaybeElement {
Element e;
YesMaybeElement() { this = TElement(e) }
override string toString() { result = e.toString() }
override Location getLocation() { result = e.getLocation() }
}
@@ -21,14 +24,15 @@ class NoMaybeElement extends MaybeElement {
NoMaybeElement() { this = TNoElement() }
override string toString() { result = "<none>" }
override Location getLocation() { none() }
}
MaybeElement qualifier(ThisAccess t) {
if exists(t.getQualifier())
then result = TElement(t.getQualifier())
else result = TNoElement()
if exists(t.getQualifier()) then result = TElement(t.getQualifier()) else result = TNoElement()
}
from ThisAccess t
select t, qualifier(t)
query predicate extensionReceiverAcc(ExtensionReceiverAccess va) { any() }

View File

@@ -6,16 +6,21 @@ varAcc
| variables.kt:16:11:16:18 | o |
| variables.kt:16:11:16:18 | o |
| variables.kt:16:11:16:18 | this.o |
| variables.kt:24:9:24:9 | this |
| variables.kt:25:9:25:9 | this |
| variables.kt:27:9:27:12 | this |
| variables.kt:28:9:28:12 | this |
extensionReceiverAcc
| variables.kt:24:9:24:9 | this |
| variables.kt:25:9:25:9 | this |
| variables.kt:27:9:27:12 | this |
| variables.kt:28:9:28:12 | this |
instAcc
| variables.kt:3:5:3:21 | this |
| variables.kt:16:11:16:18 | this |
| variables.kt:21:9:21:9 | this |
| variables.kt:21:11:21:15 | this |
| variables.kt:24:9:24:9 | this |
| variables.kt:25:9:25:9 | this |
| variables.kt:26:9:26:12 | C2.this |
| variables.kt:27:9:27:12 | this |
| variables.kt:28:9:28:12 | this |
| variables.kt:31:9:31:15 | C2.this |
| variables.kt:32:9:32:15 | C2.this |
| variables.kt:41:13:41:16 | this |

View File

@@ -2,6 +2,8 @@ import java
query predicate varAcc(VarAccess va) { any() }
query predicate extensionReceiverAcc(ExtensionReceiverAccess va) { any() }
query predicate instAcc(InstanceAccess ia) { any() }
query predicate instAccQualifier(InstanceAccess ia, Expr e) { ia.getQualifier() = e }