mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-15 17:05:03 +01:00
Start typechecking generics
This commit is contained in:
parent
bf73203182
commit
01d4238269
15 changed files with 248 additions and 19 deletions
|
|
@ -107,6 +107,7 @@ function resolveModule(
|
|||
});
|
||||
|
||||
const scopes: string[] = [];
|
||||
let tyParamScopes: string[] = [];
|
||||
|
||||
const popScope = (expected: string) => {
|
||||
const popped = scopes.pop();
|
||||
|
|
@ -130,6 +131,18 @@ function resolveModule(
|
|||
}
|
||||
}
|
||||
|
||||
for (let i = tyParamScopes.length - 1; i >= 0; i--) {
|
||||
const candidate = tyParamScopes[i];
|
||||
|
||||
if (candidate === ident.name) {
|
||||
return {
|
||||
kind: "tyParam",
|
||||
index: i,
|
||||
name: ident.name,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const item = items.get(ident.name);
|
||||
if (item !== undefined) {
|
||||
return {
|
||||
|
|
@ -214,6 +227,13 @@ function resolveModule(
|
|||
defPath,
|
||||
};
|
||||
}
|
||||
case "type": {
|
||||
tyParamScopes = item.generics.map(({name}) => name);
|
||||
|
||||
const type = { ...superFoldItem(item, this) };
|
||||
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return { ...superFoldItem(item, this), defPath };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue