Skip to content

Commit 1d55051

Browse files
Fix scala#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 b9f219b commit 1d55051

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
@@ -820,7 +820,7 @@ object desugar {
820820
val moduleName = tdef.name.toTermName
821821
val localRef = Select(Ident(moduleName), tdef.name)
822822
localRef.pushAttachment(SuppressAccessCheck, ())
823-
val aliasType = cpy.TypeDef(tdef)(rhs = completeForwarder(localRef))
823+
val aliasType = cpy.TypeDef(tdef)(rhs = completeForwarder(localRef)).withSpan(Span(MaxOffset))
824824
val localType = tdef.withMods(Modifiers(Synthetic | Opaque).withPrivateWithin(tdef.name))
825825

826826
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)