Skip to content

Set zero span for synthetic enum import selector #14498

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

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,11 @@ object desugar {
enumCases.last.pushAttachment(DesugarEnums.DefinesEnumLookupMethods, ())
val enumCompanionRef = TermRefTree()
val enumImport =
Import(enumCompanionRef, enumCases.flatMap(caseIds).map(ImportSelector(_)))
Import(enumCompanionRef, enumCases.flatMap(caseIds).map(
enumCase =>
ImportSelector(enumCase.withSpan(enumCase.span.startPos))
)
)
(enumImport :: enumStats, enumCases, enumCompanionRef)
}
else (stats, Nil, EmptyTree)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,13 @@ class HoverTest {
// sp the top-level definitions should be enclosed in an object called `Source0$package`.
.hover(m1 to m2, hoverContent("(hello.Source0$package : hello.Source0$package.type)"))
}

@Test def enumsRepeated: Unit = {
code"""|package example
|object SimpleEnum:
| enum Color:
| case ${m1}Red${m2}, Green, Blue
|""".withSource
.hover(m1 to m2, hoverContent("example.SimpleEnum.Color"))
}
}