Invalidate cached noop typechecks during typealias instantiation - #1717
Conversation
9b7521d to
08bfcd0
Compare
08bfcd0 to
96a58f7
Compare
There was a problem hiding this comment.
Nested unions still suffer from the same issue:
typealias Flat<A, B> = A | B
res_flat = new Dynamic {} is Flat<module, module>
typealias Nested<A, B> = (A | A) | (B | B)
res_nested = new Dynamic {} is Nested<module, module>Results in
res_flat = false
res_nested = true
Children should be invalidated before parents. The truffle visitor does the opposite (goes from parent to children).
2d43f82 to
5880b9d
Compare
…always-lazy alias type checking
5880b9d to
3d3d68f
Compare
There was a problem hiding this comment.
I don't think we need an invalidate() method. Instead, we can just call if (elementTypeNode.isNoopTypeCheck()) inside the execute methods of these nodes.
invalidate() suggests that a type node has stale state. But, the core problem is that we don't know yet if this is a noop check yet when inside the constructor of ListTypeNode, SetTypeNode, etc.
We can probably also change the isNoopTypeCheck method in class TypeVariableNode to this:
@Override
public boolean isNoopTypeCheck() {
CompilerDirectives.transferToInterpreter();
throw exceptionBuilder().bug("isNoopTypeCheck called on an unreplaced type variable").build();
}
Are you suggesting removing the
This particular change isn't safe since |
Ah, gotcha. Then, yeah, we should keep that impl as-is for now (it basically stands for
Yup! Or, possibly, defer setting that field until |
|
An alternate approach here is having |
#1722 implements this approach. I think this is probably preferable to this PR as it avoids losing the caching optimization in non-type-parameter scenarios. |
This also fixes
TypeAliasTypeNodealways performing lazy type checks even when they should be eager.Resolves #1710
Resolves #1716