compiler: check overloaded methods for safeness one more time

It's possible that overloaded method is marked as `safe` in manifest, so
that it must have `save` field set to true after its name was
overwritten.
This commit is contained in:
Anna Shaleva 2022-01-20 21:13:35 +03:00
parent fa1174ec7e
commit 9c2e92d7d9
2 changed files with 8 additions and 1 deletions

View file

@ -461,6 +461,13 @@ func (di *DebugInfo) ConvertToManifest(o *Options) (*manifest.Manifest, error) {
"multiple methods with the same number of parameters", name)
}
m.Name = emitName
// Check the resulting name against set of safe methods.
for i := range o.SafeMethods {
if m.Name == o.SafeMethods[i] {
m.Safe = true
break
}
}
}
return result, nil
}

View file

@ -129,7 +129,7 @@ func checkMethod(m *manifest.Manifest, expected *manifest.Method,
}
}
if expected.Safe != actual.Safe {
return fmt.Errorf("%w: expected %t", ErrSafeMethodMismatch, expected.Safe)
return fmt.Errorf("'%s' %w: expected %t", expected.Name, ErrSafeMethodMismatch, expected.Safe)
}
return nil
}