Address review comments

This commit is contained in:
Tom Hvitved
2025-03-13 21:10:48 +01:00
parent 255f06b65a
commit c3739d4f23
2 changed files with 9 additions and 10 deletions

View File

@@ -27,6 +27,6 @@ module Impl {
*/
class CallExprBase extends Generated::CallExprBase {
/** Gets the static target of this call, if any. */
Callable getStaticTarget() { none() } // overridden by subclasses
Callable getStaticTarget() { none() } // overridden by subclasses, but cannot be made abstract
}
}

View File

@@ -295,6 +295,11 @@ abstract class ImplOrTraitItemNode extends ItemNode {
predicate hasAssocItem(string name) { name = this.getAnAssocItem().getName() }
}
pragma[nomagic]
private TypeParamItemNode resolveTypeParamPathTypeRepr(PathTypeRepr ptr) {
result = resolvePath(ptr.getPath())
}
class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
Path getSelfPath() { result = super.getSelfTy().(PathTypeRepr).getPath() }
@@ -310,12 +315,6 @@ class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
this.getSelfPath().getPart().getGenericArgList().getAGenericArg().(TypeArg).getTypeRepr()
}
pragma[nomagic]
private TypeParamItemNode getASelfTyTypeParamArg(TypeRepr arg) {
arg = this.getASelfTyArg() and
result = resolvePath(arg.(PathTypeRepr).getPath())
}
/**
* Holds if this `impl` block is not fully parametric. That is, the implementing
* type is generic and the implementation is not parametrically polymorphic in all
@@ -340,9 +339,9 @@ class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
pragma[nomagic]
predicate isNotFullyParametric() {
exists(TypeRepr arg | arg = this.getASelfTyArg() |
not exists(this.getASelfTyTypeParamArg(arg))
not exists(resolveTypeParamPathTypeRepr(arg))
or
this.getASelfTyTypeParamArg(arg).hasTraitBound()
resolveTypeParamPathTypeRepr(arg).hasTraitBound()
)
}
@@ -500,7 +499,7 @@ private class TypeParamItemNode extends ItemNode instanceof TypeParam {
exists(this.getABoundPath())
or
exists(ItemNode declaringItem, WherePred wp |
this = resolvePath(wp.getTypeRepr().(PathTypeRepr).getPath()) and
this = resolveTypeParamPathTypeRepr(wp.getTypeRepr()) and
wp = declaringItem.getADescendant() and
this = declaringItem.getADescendant()
)