Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Name-resolution and selector issues can omit valid extensions and members, suppress model-only types, and create spurious or duplicate class-like elements.
4 open issues
What changed in this PR
Introduces ClassLikeElement as a shared representation for declared types, their extensions, and types known only from models.
Changes:
- Adds and exports the canonical class/type API.
- Migrates type inference, model matching, and member lookup to use it.
| File | Description |
|---|---|
unified/ql/src/queries/security/CWE-312/CleartextLogging.ql |
Uses canonical elements for logging-member detection. |
unified/ql/lib/utils/test/TestUtils.qll |
Updates member-name qualification. |
unified/ql/lib/unified.qll |
Exports the new API. |
unified/ql/lib/codeql/unified/internal/typeinference/TypeMention.qll |
Updates type-mention and model-selector handling. |
unified/ql/lib/codeql/unified/internal/typeinference/TypeInferencePluginSwift.qll |
Migrates Swift type classifiers. |
unified/ql/lib/codeql/unified/internal/typeinference/TypeInference.qll |
Updates inference to use canonical types. |
unified/ql/lib/codeql/unified/internal/typeinference/TypeAbstraction.qll |
Updates a type name in documentation only. |
unified/ql/lib/codeql/unified/internal/typeinference/Type.qll |
Unifies declaration-backed and model-only types. |
unified/ql/lib/codeql/unified/internal/StaticNameBinding.qll |
Exposes cached extension-target resolution. |
unified/ql/lib/codeql/unified/internal/mad/LegacyMaD.qll |
Connects model selectors to canonical elements. |
unified/ql/lib/codeql/unified/internal/FacadeAst.qll |
Adds element access and refactors extension handling. |
unified/ql/lib/codeql/unified/internal/ClassLikeElement.qll |
Defines canonical elements and their declaration/member relationships. |
Review effort: Max (adaptive)
| cached | ||
| private newtype TClassLikeElement = | ||
| TClassLikeDeclarationElement(ClassLikeDeclaration decl) { not exists(decl.getExtensionTarget()) } or | ||
| TTypeSelectorElement(MaD::TypeSelector selector) { not exists(selector.getDeclaration()) } |
There was a problem hiding this comment.
This is blocked on getting models to refer to types by their module-qualified names, e.g. Foundation.URL instead of URL. There is just no way to tell which class is the intended target right now.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Constructor calls and subtype declarations referring to a modeled type via a type alias were not matched by models. Make TypeSelector.getAStaticRef follow type aliases, and keep an unexpanded variant for type mentions, which must resolve alias references to the alias type itself. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
61f2d13 to
40c327e
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Alias extension prefixes are not expanded, causing nested types to miss matching declarations and create separate model-only elements; alias expansion and regression coverage are needed.
2 open issues
3 resolved since last review
Review effort: Balanced (adaptive)
Expand extension target type aliases when deriving nested declaration names, so a nested declaration in an aliased model-only extension shares the modeled type's qualified name. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Smaller change split out from this PR.
Introduces
ClassLikeElementas a representative for a class/type. This serves two purposes:ClassLikeElement. Predicates likegetAMemberIncludingExtensionsare refactored to go throughClassLikeElement.ClassLikeElement, making it possible to write code that handles both situations under one pipeline.