Fix bug where some methods were inappropriately promoted

This commit is contained in:
Owen Mansel-Chan
2024-09-24 15:03:48 +01:00
parent 0255edf524
commit 6e428d5083
2 changed files with 15 additions and 15 deletions

View File

@@ -1000,7 +1000,7 @@ class NamedType extends @namedtype, CompositeType {
s.hasOwnField(_, _, embedded, true) and
// ensure `m` can be promoted
not s.hasOwnField(_, m, _, _) and
not exists(Method m2 | m2.getReceiverType() = this and m2.getName() = m)
not exists(Method m2 | m2.getReceiverBaseType() = this and m2.getName() = m)
|
// If S contains an embedded field T, the method set of S includes promoted methods with receiver T
result = embedded.getMethod(m)

View File

@@ -7,83 +7,83 @@ import (
func TestI1(t test.I1) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t] SImplEmbedI1[t]
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t]
}
func TestI2(t test.I2) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[t] I2[f] I2[t] IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t] SImplEmbedI1[t] SImplEmbedI2[t]
t.Sink(y) // $ I1[t] I2[f] I2[t] IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t]
}
func TestS1(t test.S1) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[t] IEmbedI1[t] S1[f] S1[t] SEmbedI1[t] SImplEmbedI1[t]
t.Sink(y) // $ I1[t] IEmbedI1[t] S1[f] S1[t] SEmbedI1[t]
}
func TestS2(t test.S2) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[t] I2[t] IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t] SImplEmbedI1[t] SImplEmbedI2[t]
t.Sink(y) // $ I1[t] I2[t] IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t]
}
func TestSEmbedI1(t test.SEmbedI1) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t] SImplEmbedI1[t]
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t]
}
func TestSEmbedI2(t test.SEmbedI2) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[t] I2[f] I2[t] IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t] SImplEmbedI1[t] SImplEmbedI2[t]
t.Sink(y) // $ I1[t] I2[f] I2[t] IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t]
}
func TestIEmbedI1(t test.IEmbedI1) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t] SImplEmbedI1[t]
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t]
}
func TestIEmbedI2(t test.IEmbedI2) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[t] I2[f] I2[t] IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t] SImplEmbedI1[t] SImplEmbedI2[t]
t.Sink(y) // $ I1[t] I2[f] I2[t] IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t]
}
func TestSImplEmbedI1(t test.SImplEmbedI1) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[t] IEmbedI1[t] SEmbedI1[t] SImplEmbedI1[t]
t.Sink(y) // $ I1[t] IEmbedI1[t] SEmbedI1[t] SImplEmbedI1[t]
}
func TestSImplEmbedI2(t test.SImplEmbedI2) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[t] I2[t] IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t] SImplEmbedI1[t] SImplEmbedI2[t]
t.Sink(y) // $ I1[t] I2[t] IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t] SImplEmbedI2[t]
}
func TestSEmbedS1(t test.SEmbedS1) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[t] IEmbedI1[t] S1[f] S1[t] SEmbedI1[t] SImplEmbedI1[t]
t.Sink(y) // $ I1[t] IEmbedI1[t] S1[f] S1[t] SEmbedI1[t]
}
func TestSEmbedS2(t test.SEmbedS2) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[t] I2[t] IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t] SImplEmbedI1[t] SImplEmbedI2[t]
t.Sink(y) // $ I1[t] I2[t] IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t]
}
func TestSImplEmbedS1(t test.SImplEmbedS1) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[t] IEmbedI1[t] SEmbedI1[t] SImplEmbedI1[t] SImplEmbedS1[t]
t.Sink(y) // $ I1[t] IEmbedI1[t] SEmbedI1[t] SImplEmbedS1[t]
}
func TestSImplEmbedS2(t test.SImplEmbedS2) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[t] I2[t] IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t] SImplEmbedI1[t] SImplEmbedI2[t] SImplEmbedS2[t]
t.Sink(y) // $ I1[t] I2[t] IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t] SImplEmbedS2[t]
}