Swift: restrict Type.ql for deduplication test

This commit is contained in:
Paolo Tranquilli
2023-03-14 15:56:47 +01:00
parent b6146478dc
commit 2eb82fede7
5 changed files with 23 additions and 22 deletions

View File

@@ -1,15 +1,15 @@
| Sources/deduplication/def.swift:1:1:1:9 | var ... = ... | PatternBindingDecl |
| Sources/deduplication/def.swift:1:5:1:5 | x | ConcreteVarDecl |
| Sources/deduplication/def.swift:1:1:1:15 | var ... = ... | PatternBindingDecl |
| Sources/deduplication/def.swift:1:5:1:5 | def_int | ConcreteVarDecl |
| Sources/deduplication/def.swift:3:1:3:20 | Generic | StructDecl |
| Sources/deduplication/def.swift:3:8:3:8 | Generic<T>.init() | Initializer |
| Sources/deduplication/def.swift:3:8:3:8 | self | ParamDecl |
| Sources/deduplication/def.swift:3:16:3:16 | T | GenericTypeParamDecl |
| Sources/deduplication/def.swift:5:1:5:41 | var ... = ... | PatternBindingDecl |
| Sources/deduplication/def.swift:5:5:5:5 | instantiated_generic | ConcreteVarDecl |
| Sources/deduplication/def.swift:7:1:7:42 | function(_:) | NamedFunction |
| Sources/deduplication/def.swift:7:15:7:18 | _ | ParamDecl |
| Sources/deduplication/use.swift:1:1:1:13 | var ... = ... | PatternBindingDecl |
| Sources/deduplication/use.swift:1:5:1:5 | use_x | ConcreteVarDecl |
| Sources/deduplication/def.swift:5:1:5:45 | var ... = ... | PatternBindingDecl |
| Sources/deduplication/def.swift:5:5:5:5 | def_instantiated_generic | ConcreteVarDecl |
| Sources/deduplication/def.swift:7:1:7:46 | def_function(_:) | NamedFunction |
| Sources/deduplication/def.swift:7:19:7:22 | _ | ParamDecl |
| Sources/deduplication/use.swift:1:1:1:15 | var ... = ... | PatternBindingDecl |
| Sources/deduplication/use.swift:1:5:1:5 | use_int | ConcreteVarDecl |
| Sources/deduplication/use.swift:2:1:2:32 | var ... = ... | PatternBindingDecl |
| Sources/deduplication/use.swift:2:5:2:5 | use_instantiated_generic | ConcreteVarDecl |
| Sources/deduplication/use.swift:3:1:3:20 | var ... = ... | PatternBindingDecl |

View File

@@ -1,7 +1,7 @@
var x = 42
var def_int = 42
struct Generic<T> {}
var instantiated_generic = Generic<Int>()
var def_instantiated_generic = Generic<Int>()
func function(_: Int) -> Int { return 42 }
func def_function(_: Int) -> Int { return 42 }

View File

@@ -1,3 +1,3 @@
let use_x = x
let use_instantiated_generic = instantiated_generic
let use_function = function
let use_int = def_int
let use_instantiated_generic = def_instantiated_generic
let use_function = def_function

View File

@@ -1,8 +1,4 @@
| (Int) -> Int | FunctionType | function(_:) |
| (Int) -> Int | FunctionType | def_function(_:) |
| (Int) -> Int | FunctionType | use_function |
| <T> (Generic<T>.Type) -> () -> Generic<T> | GenericFunctionType | Generic<T>.init() |
| Generic<Int> | BoundGenericStructType | instantiated_generic, use_instantiated_generic |
| Generic<T> | BoundGenericStructType | self |
| Generic<T>.Type | MetatypeType | Generic |
| Int | StructType | _, use_x, x |
| T.Type | MetatypeType | T |
| Generic<Int> | BoundGenericStructType | def_instantiated_generic, use_instantiated_generic |
| Int | StructType | def_int, use_int |

View File

@@ -3,5 +3,10 @@ import Relevant
from Type t, string decls
where
decls = strictconcat(ValueDecl d | relevant(d) and t = d.getInterfaceType() | d.toString(), ", ")
decls =
strictconcat(ValueDecl d |
relevant(d) and t = d.getInterfaceType() and d.toString().matches(["use_%", "def_%"])
|
d.toString(), ", "
)
select t, t.getPrimaryQlClasses(), decls