Fixed vptr condition on static methods
This commit is contained in:
@@ -51,8 +51,10 @@ impl ClassProcessedData {
|
||||
if matches!(method.item.visibility, Visibility::Public) {
|
||||
match &method.item.is_override {
|
||||
None => {
|
||||
if method.item.is_using_self() {
|
||||
v_table.push(method.item.name.clone());
|
||||
}
|
||||
}
|
||||
Some(override_spec) => {
|
||||
override_v_table
|
||||
.entry(override_spec.clone())
|
||||
@@ -412,18 +414,7 @@ impl ClassProcessedData {
|
||||
for method in &self.methods {
|
||||
match method.item.visibility {
|
||||
Visibility::Public => {
|
||||
let is_using_self = match method.item.params.0.get(0) {
|
||||
Some(VarDecl { name, .. }) => {
|
||||
if let Pattern::Path(_, v) = name {
|
||||
v.0.len() == 1 && v.0[0].0 == "self"
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
|
||||
if is_using_self {
|
||||
if method.item.is_using_self() {
|
||||
if method.item.is_override.is_none() {
|
||||
gen_method_point(&method.item, ctx, cg);
|
||||
}
|
||||
|
||||
@@ -125,3 +125,18 @@ pub struct FieldDeclStmt {
|
||||
pub decl: FieldDecl,
|
||||
pub init: Option<Expression>,
|
||||
}
|
||||
|
||||
impl FunctionDecl {
|
||||
pub fn is_using_self(&self) -> bool {
|
||||
match self.params.0.get(0) {
|
||||
Some(VarDecl { name, .. }) => {
|
||||
if let Pattern::Path(_, v) = name {
|
||||
v.0.len() == 1 && v.0[0].0 == "self"
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ pub class Animal<T> {
|
||||
pub fn test_speak(*self) {
|
||||
self.speak();
|
||||
}
|
||||
|
||||
pub fn static_method() {}
|
||||
}
|
||||
|
||||
pub class Mammal<T> : Animal<T> {
|
||||
|
||||
Reference in New Issue
Block a user