mirror of
https://github.com/enso-org/enso.git
synced 2024-11-23 08:08:34 +03:00
Fix attaching generic annotations (#9234)
Fixes the issue with attaching generic annotations in complex types. Annotations in the type body could be lost during the compilation if its constructor was defined at the end of the type definition.
This commit is contained in:
parent
44a1d9138b
commit
fad1b45bcf
@ -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,
|
||||
@ -125,6 +125,7 @@ case object ComplexType extends IRPass {
|
||||
lastAnnotations = Seq()
|
||||
res
|
||||
case _ =>
|
||||
lastAnnotations = Seq()
|
||||
None
|
||||
}
|
||||
// TODO[MK] this is probably removable
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user