Skip to content

Commit

Permalink
bugfix: Case completions in summonFrom
Browse files Browse the repository at this point in the history
  • Loading branch information
jkciesluk committed Mar 22, 2024
1 parent 63a0738 commit 8e97536
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Expand Up @@ -26,6 +26,7 @@ import dotty.tools.dotc.core.Symbols.NoSymbol
import dotty.tools.dotc.core.Symbols.Symbol
import dotty.tools.dotc.core.Types.AndType
import dotty.tools.dotc.core.Types.ClassInfo
import dotty.tools.dotc.core.Types.NoType
import dotty.tools.dotc.core.Types.OrType
import dotty.tools.dotc.core.Types.Type
import dotty.tools.dotc.core.Types.TypeRef
Expand Down Expand Up @@ -94,7 +95,7 @@ object CaseKeywordCompletion:
Some(sel.tpe.widen.metalsDealias)

selTpe
.map { selTpe =>
.collect { case selTpe if selTpe != NoType =>
val selectorSym = selTpe.typeSymbol
// Special handle case when selector is a tuple or `FunctionN`.
if definitions.isTupleClass(selectorSym) || definitions.isFunctionClass(
Expand Down
33 changes: 33 additions & 0 deletions tests/cross/src/test/scala/tests/pc/CompletionCaseSuite.scala
Expand Up @@ -833,4 +833,37 @@ class CompletionCaseSuite extends BaseCompletionSuite {
filter = _.contains("exhaustive")
)

check(
"summonFrom".tag(IgnoreScala2),
"""
|object A {
| import scala.compiletime.summonFrom
| class A
|
| inline def f: Any = summonFrom {
| case x@@: A => ??? // error: ambiguous givens
| }
|}
|""".stripMargin,
""
)

check(
"summonFrom1".tag(IgnoreScala2),
"""
|object A {
| import scala.compiletime.summonFrom
|
| class A
| given a1: A = new A
| given a2: A = new A
|
| inline def f: Any = summonFrom {
| case x@@: A => ??? // error: ambiguous givens
| }
|}
|""".stripMargin,
""
)

}

0 comments on commit 8e97536

Please sign in to comment.