Implement Typed IR#504
Conversation
This will be replaced with `Symbol.erasedType`.
`Call`, `Lambda`, `Select`, and `DynSelect` is left for a future commit.
LPTK
left a comment
There was a problem hiding this comment.
Some possible next immediate steps:
- Update printer to show the erased types at variable and member declaration/definition sites.
- Update
Loweringso it generates erased types from parameter type annotations, to be used to annotate the correspondingVarSymbol. - Make sure we are never overriding an existing erased type in a given symbol by using
softAssert, as a sanity check.
A subtlety we should get right: the erasure of annotated class parameter types should successfully propagate to their defining fields. Param has a ``fldSym` which can be used for this.
| new Rewriter(instId).applyBlock(ogBody), | ||
| mkReturnCall(restFunSym, restFunArgs)) | ||
| val refreshedFvSymbols = dtorBranchFnFvs(branchId._1).map(s => s -> new VarSymbol(Tree.Ident(s"fv_${s.nme}"))) | ||
| val refreshedFvSymbols = dtorBranchFnFvs(branchId._1).map(s => s -> new VarSymbol(Tree.Ident(s"fv_${s.nme}"), erasedType = N)) |
There was a problem hiding this comment.
It seems many cases like this one should carry over the previous erasedType somehow.
|
The current task list (work items created by me, organized by AI):
|
What does that mean?
This should be moved to phase B. In fact, it's the first thing yoiu should do, just so you can actually see what you're doing! |
Good point, I have updated to task list. |
Refinement of types during Lowering is implemented later.
|
Implemented this week:
Remaining Items as of this week:
Additional good-to-have refactoring:
All of these will be worked on the week after, and I'll go through the entire patchset and clean it up before marking this as ready for review. |
| blockImpl(stats, res) | ||
| case DefineVar(sym, rhs) :: stats => | ||
| term(rhs): r => | ||
| // Seed the binding's erased type before lowering the continuation, so that a later use of |
| // A local consumed by a *later* statement in the same (non-hoisted) block is | ||
| // seeded before that statement is lowered, so its erased type survives: both `n` | ||
| // and the forward use `m` stay `Int`, and the inferred return is `Int`. |
There was a problem hiding this comment.
This is all bs and not what I asked you to do at all. It's not the right design. I've already told you the types of variables are to be resolved by a resolver pass before Lowering. I never asked you to reimplement a broken and incomplete form of type inference...
You need to slow down with Claude, take a step back, and actually think about the design and about what your actual task is. And ask me before you make such choices in the design of the compiler.
|
TODO:
|
| /** The types are the same. */ | ||
| case Identity | ||
| /** The value type is a subtype of the target type. */ | ||
| case Upcast |
| /** How a value's erased type relates to the erased type of the slot it flows into. */ | ||
| enum CastKind: | ||
| /** The types are the same. */ | ||
| case Identity |
| /** The value type is a supertype of the target type. */ | ||
| case Downcast | ||
| /** The types are provably incompatible. */ | ||
| case Unrelated |
| * | ||
| * - `rsc` is true if this reference is a resource class. | ||
| */ | ||
| case class AnyRef(rsc: Bool, csym: ClassLikeSymbol | NoSymbol.type) extends ErasedType, ErasedValueType: |
There was a problem hiding this comment.
Tip: make ErasedValueType an abstract base class and you will only need extends ErasedValueType.
No description provided.