-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify BindingsMap
by instead relying on StaticModuleScope
for atom type resolution
#11955
base: wip/radeusgd/9812-infer-method-calls
Are you sure you want to change the base?
Conversation
…n next iteration" This reverts commit 5be3b82.
…sing out AtomTypeInterface
31934b9
to
919086a
Compare
…d, we are on good path Expected x1 = ((My_Constructor) 1) to have the right atom type: expected:<[project.modA.My_Type]> but was:<[Standard.Base.Data.Numbers.Float]>
case class Argument( | ||
name: String, | ||
hasDefaultValue: Boolean, | ||
typReference: Reference[Expression] | ||
) { | ||
def typ(): Option[Expression] = Option( | ||
typReference.get(classOf[Expression]) | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes the infamous cycle from the IR - the Expression
holding the type of the constructor is no longer needed.
That's because we process this type Expression
in StaticModuleScopeAnalysis
and save it in StaticModuleScope
metadata as an already processed TypeRepresentation
- so it is no longer IR that is stored inside of metadata, but a simpler data structure representing our types.
registerFieldGetters(scopeBuilder, atomTypeScope, typ); | ||
} | ||
|
||
private TypeRepresentation buildAtomConstructorType( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mostly moved from the TypeResolver
.
@@ -51,8 +51,7 @@ public QualifiedName getAssociatedType() { | |||
* <p>Instances that are assigned this type are built with one of the available constructors, but | |||
* statically we do not necessarily know which one. | |||
*/ | |||
record AtomType(QualifiedName fqn, AtomTypeInterface typeInterface) | |||
implements TypeRepresentation { | |||
record AtomType(QualifiedName fqn) implements TypeRepresentation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our type representation is no longer holding references to some complex AtomTypeInterface
structure which internally was holding references to BindingsMap and was overall ugly.
Now the TypeRepresentation
is a plain data type. The information about Atom type interface is instead encoded in the StaticModuleScope
, like information about method already has been.
BindingsMap
by instead relying on StaticModuleScope
for atom type resolution
@JaroslavTulach shall we maybe disable the support for cycles in IR persistence now? I think we are no longer relying on it and there were issues with it from time to time so maybe we should change the code to fail on cycles and keep an eye on us accidentally re-introducing these problematic cycles? btw. I think the cycles could have been also why @Akirathan could not use equality for comparing IR and had to resort to identity. I'm not sure if we had any other cycles than this one? If not, maybe we could try to come back to equality over identity then. |
Pull Request Description
AtomTypeInterface
- it was a useful temporary hack, but in the longer term it seemed to not really solve the problem we had.StaticModuleScope
, so I can remove theExpression
fromBindingsMap
. I think that storing IR inside of metadata attached to said IR (which was the reason for introducing cycles) was a bad idea after all.TypeRepresentation
is greatly simplified - it no longer refences complicated objects likeAtomTypeInterface
(which had a nice API but ugly internals, and the internals were affecting serialization). NowTypeRepresentation
becomes just plain data, a much simpler representation and I think it is closer to what it was supposed to be from the beginning.Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
or the Snowflake database integration, a run of the Extra Tests has been scheduled.