Skip to content
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

Fix attaching generic annotations #9234

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.enso.compiler.pass.analyse.{
TailCall
}
import org.enso.compiler.pass.lint.UnusedBindings
import org.enso.compiler.pass.optimise.{LambdaConsolidate}
import org.enso.compiler.pass.optimise.LambdaConsolidate
import org.enso.compiler.pass.resolve.{
DocumentationComments,
IgnoredBindings,
Expand Down Expand Up @@ -125,6 +125,7 @@ case object ComplexType extends IRPass {
lastAnnotations = Seq()
res
case _ =>
lastAnnotations = Seq()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected place of fix - I was searching for the problem in GenericAnnotations...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The annotation was lost here in the ComplexType compiler phase, and later GenericAnnotations was processing IR without the annotation node.

None
}
// TODO[MK] this is probably removable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ class ComplexTypeTest extends CompilerTest {
tp.members(1).name.name shouldEqual "Bar"
}

"have their annotations correct" in {
val ir =
"""
|type MyType
| @a 42
| bar self = self
|
| Foo
|""".stripMargin.preprocessModule.desugar
ir.bindings.length shouldEqual 3

val tp = ir.bindings(0).asInstanceOf[Definition.Type]
tp.name.name shouldEqual "MyType"
tp.members(0).name.name shouldEqual "Foo"

val a = ir.bindings(1).asInstanceOf[Name.GenericAnnotation]
a.name shouldEqual "a"

val bar = ir.bindings(2).asInstanceOf[definition.Method.Binding]
bar.methodName.name shouldEqual "bar"
}

"have their methods desugared to binding methods" in {
ir.bindings(3) shouldBe an[definition.Method.Binding]
val isJust = ir.bindings(3).asInstanceOf[definition.Method.Binding]
Expand Down
Loading