File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,14 @@ module Impl {
2323 * ```
2424 */
2525 class ImplTraitTypeRepr extends Generated:: ImplTraitTypeRepr {
26- /**
27- * Gets the function for which this impl trait type occurs in the return
28- * type, if any.
29- */
30- Function getFunctionReturnPos ( ) { this .getParentNode * ( ) = result .getRetType ( ) .getTypeRepr ( ) }
26+ /** Gets the function for which this impl trait type occurs, if any. */
27+ Function getFunction ( ) {
28+ this .getParentNode * ( ) = [ result .getRetType ( ) .getTypeRepr ( ) , result .getAParam ( ) .getTypeRepr ( ) ]
29+ }
30+
31+ /** Holds if this impl trait type occurs in the return type of a function. */
32+ predicate isInReturnPos ( ) {
33+ this .getParentNode * ( ) = this .getFunction ( ) .getRetType ( ) .getTypeRepr ( )
34+ }
3135 }
3236}
Original file line number Diff line number Diff line change @@ -60,7 +60,8 @@ newtype TType =
6060 TSliceTypeParameter ( )
6161
6262predicate implTraitTypeParam ( ImplTraitTypeRepr implTrait , int i , TypeParam tp ) {
63- tp = implTrait .getFunctionReturnPos ( ) .getGenericParamList ( ) .getTypeParam ( i ) and
63+ implTrait .isInReturnPos ( ) and
64+ tp = implTrait .getFunction ( ) .getGenericParamList ( ) .getTypeParam ( i ) and
6465 // Only include type parameters of the function that occur inside the impl
6566 // trait type.
6667 exists ( Path path | path .getParentNode * ( ) = implTrait and resolvePath ( path ) = tp )
@@ -317,7 +318,7 @@ class DynTraitType extends Type, TDynTraitType {
317318class ImplTraitReturnType extends ImplTraitType {
318319 private Function function ;
319320
320- ImplTraitReturnType ( ) { function = impl .getFunctionReturnPos ( ) }
321+ ImplTraitReturnType ( ) { impl . isInReturnPos ( ) and function = impl .getFunction ( ) }
321322
322323 override Function getFunction ( ) { result = function }
323324}
You can’t perform that action at this time.
0 commit comments