Skip to content

Commit bef2849

Browse files
Fix #6415: Enable REPL code completion for opaque types
The completion did not work because the desugared version of the opaque type's definition shared the span with its private definition inside the companion object.
1 parent a7dbb6c commit bef2849

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ object desugar {
828828
val moduleName = tdef.name.toTermName
829829
val localRef = Select(Ident(moduleName), tdef.name)
830830
localRef.pushAttachment(SuppressAccessCheck, ())
831-
val aliasType = cpy.TypeDef(tdef)(rhs = completeForwarder(localRef))
831+
val aliasType = cpy.TypeDef(tdef)(rhs = completeForwarder(localRef)).withSpan(tdef.span.startPos)
832832
val localType = tdef.withMods(Modifiers(Synthetic | Opaque).withPrivateWithin(tdef.name))
833833

834834
val companions = moduleDef(ModuleDef(

compiler/test/dotty/tools/repl/TabcompleteTests.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,8 @@ class TabcompleteTests extends ReplTest {
128128
@Test def moduleCompletion = fromInitialState { implicit s =>
129129
assertEquals(List("Predef"), tabComplete("object Foo { type T = Pre"))
130130
}
131+
132+
@Test def i6415 = fromInitialState { implicit s =>
133+
assertEquals(List("Predef"), tabComplete("opaque type T = Pre"))
134+
}
131135
}

0 commit comments

Comments
 (0)