@@ -306,27 +306,35 @@ module SourceSinkInterpretationInput implements
306
306
or
307
307
// `syntacticQualBaseType`'s underlying type might be a struct type and `sse`
308
308
// might be a promoted method or field in it.
309
- exists ( StructType st , Field field1 , Field field2 , int depth1 , int depth2 , Type t2 |
310
- st = syntacticQualBaseType .getUnderlyingType ( ) and
311
- field1 = st .getFieldAtDepth ( _, depth1 ) and
312
- field2 = st .getFieldAtDepth ( _, depth2 ) and
313
- targetType = lookThroughPointerType ( field1 .getType ( ) ) and
314
- t2 = lookThroughPointerType ( field2 .getType ( ) ) and
315
- (
316
- field1 = field2
317
- or
318
- field2 =
319
- targetType .getUnderlyingType ( ) .( StructType ) .getFieldAtDepth ( _, depth2 - depth1 - 1 )
320
- )
321
- |
322
- sse .asEntity ( ) .( Method ) .getReceiverBaseType ( ) = t2
323
- or
324
- sse .asEntity ( ) .( Field ) .getDeclaringType ( ) = t2 .getUnderlyingType ( )
325
- )
309
+ targetType =
310
+ getIntermediateEmbeddedType ( sse .asEntity ( ) , syntacticQualBaseType .getUnderlyingType ( ) )
326
311
)
327
312
)
328
313
}
329
314
315
+ /**
316
+ * Gets the type of an embedded field of `st` which is on the path to `e`,
317
+ * which is a promoted method or field of `st`, or its base type if it's a
318
+ * pointer type.
319
+ */
320
+ private Type getIntermediateEmbeddedType ( Entity e , StructType st ) {
321
+ exists ( Field field1 , Field field2 , int depth1 , int depth2 , Type t2 |
322
+ field1 = st .getFieldAtDepth ( _, depth1 ) and
323
+ field2 = st .getFieldAtDepth ( _, depth2 ) and
324
+ result = lookThroughPointerType ( field1 .getType ( ) ) and
325
+ t2 = lookThroughPointerType ( field2 .getType ( ) ) and
326
+ (
327
+ field1 = field2
328
+ or
329
+ field2 = result .getUnderlyingType ( ) .( StructType ) .getFieldAtDepth ( _, depth2 - depth1 - 1 )
330
+ )
331
+ |
332
+ e .( Method ) .getReceiverBaseType ( ) = t2
333
+ or
334
+ e .( Field ) .getDeclaringType ( ) = t2 .getUnderlyingType ( )
335
+ )
336
+ }
337
+
330
338
/**
331
339
* Gets `underlying`, where `n` if of the form `implicitDeref?(underlying.implicitFieldRead1.implicitFieldRead2...)`
332
340
*
0 commit comments