@@ -112,44 +112,39 @@ predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) {
112112}
113113
114114private predicate summaryModel (
115- Function f , string input , string output , string kind , Provenance provenance , boolean isExact ,
115+ Function f , string input , string output , string kind , Provenance provenance , boolean isInherited ,
116116 QlBuiltins:: ExtensionId madId
117117) {
118118 exists ( string path , Function f0 |
119119 summaryModel ( path , input , output , kind , provenance , madId ) and
120120 f0 .getCanonicalPath ( ) = path
121121 |
122122 f = f0 and
123- isExact = true
123+ isInherited = false
124124 or
125125 f .implements ( f0 ) and
126- isExact = false
126+ isInherited = true
127127 )
128128}
129129
130130private predicate summaryModelRelevant (
131131 Function f , string input , string output , string kind , Provenance provenance ,
132132 QlBuiltins:: ExtensionId madId
133133) {
134- exists ( boolean isExact | summaryModel ( f , input , output , kind , provenance , isExact , madId ) |
135- (
136- provenance .isManual ( )
137- or
138- // only apply generated models to functions not defined in source code, and
139- // when there are no exact manual models for the functions
140- provenance .isGenerated ( ) and
141- not any ( Provenance manual | summaryModel ( f , _, _, _, manual , true , _) ) .isManual ( ) and
142- not f .fromSource ( )
143- ) and
144- (
145- isExact = true
146- or
147- // only apply trait models to concrete implementations when they are not
148- // defined in source code, and when there are no exact model for the functions
149- isExact = false and
150- not summaryModel ( f , _, _, _, provenance , true , _) and
151- not f .fromSource ( )
152- )
134+ exists ( boolean isInherited |
135+ summaryModel ( f , input , output , kind , provenance , isInherited , madId )
136+ |
137+ // Only apply generated or inherited models to functions in library code and
138+ // when no strictly better model exists
139+ if provenance .isGenerated ( ) or isInherited = true
140+ then
141+ not f .fromSource ( ) and
142+ not exists ( Provenance other | summaryModel ( f , _, _, _, other , false , _) |
143+ provenance .isGenerated ( ) and other .isManual ( )
144+ or
145+ provenance = other and isInherited = true
146+ )
147+ else any ( )
153148 )
154149}
155150
0 commit comments