Skip to content

Commit db9cec3

Browse files
committed
Workaround missing complitions due to non-backportable change in the upstream. Update CompletionTests
1 parent 65645e5 commit db9cec3

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

language-server/test/dotty/tools/languageserver/CompletionTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ class CompletionTest {
16591659
|""".completion(m1, Set(
16601660
("Number", Field, "scala.util.matching.Regex"),
16611661
("NumberFormatException", Module, "NumberFormatException"),
1662-
("Numeric", Field, "scala.math.Numeric")
1662+
("Numeric", Method, "=> scala.math.Numeric.type")
16631663
))
16641664

16651665
@Test def shadowedImportType: Unit =
@@ -1677,6 +1677,6 @@ class CompletionTest {
16771677
("NumberFormatException", Module, "NumberFormatException"),
16781678
("NumberFormatException", Field, "NumberFormatException"),
16791679
("Numeric", Field, "Numeric"),
1680-
("Numeric", Field, "scala.math.Numeric")
1680+
("Numeric", Method, "=> scala.math.Numeric.type")
16811681
))
16821682
}

presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,14 @@ class Completions(
231231
label: String,
232232
toCompletionValue: (String, SingleDenotation, CompletionSuffix) => CompletionValue
233233
): List[CompletionValue] =
234-
val sym = denot.symbol
234+
// Workaround for LTS due to lack of https://github.com/scala/scala3/pull/18874 backport
235+
// required after backport of https://github.com/scala/scala3/pull/18914
236+
// We use the symbol of accessor result type to make the sym compliant with the 3.4+
237+
// where we would obtain the field symbol directly
238+
val sym =
239+
val resultTpeSym = denot.info.finalResultType.typeSymbol
240+
if denot.symbol.is(Accessor) && resultTpeSym != NoSymbol then resultTpeSym
241+
else denot.symbol
235242
// find the apply completion that would need a snippet
236243
val methodDenots: List[SingleDenotation] =
237244
if shouldAddSnippet && completionMode.is(Mode.Term) &&

0 commit comments

Comments
 (0)