File tree Expand file tree Collapse file tree 2 files changed +83
-1
lines changed
test/dotty/tools/pc/tests/hover Expand file tree Collapse file tree 2 files changed +83
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ import dotty.tools.dotc.util.SourcePosition
2525import dotty .tools .pc .printer .ShortenedTypePrinter
2626import dotty .tools .pc .printer .ShortenedTypePrinter .IncludeDefaultParam
2727import dotty .tools .pc .utils .InteractiveEnrichments .*
28+ import dotty .tools .dotc .ast .untpd .InferredTypeTree
29+ import dotty .tools .dotc .core .StdNames
2830
2931object HoverProvider :
3032
@@ -131,7 +133,12 @@ object HoverProvider:
131133 .flatMap(symTpe => search.symbolDocumentation(symTpe._1, contentType))
132134 .map(_.docstring())
133135 .mkString(" \n " )
134- printer.expressionType(exprTpw) match
136+
137+ val expresionTypeOpt =
138+ if symbol.name == StdNames .nme.??? then
139+ InferExpectedType (search, driver, params).infer()
140+ else printer.expressionType(exprTpw)
141+ expresionTypeOpt match
135142 case Some (expressionType) =>
136143 val forceExpressionType =
137144 ! pos.span.isZeroExtent || (
Original file line number Diff line number Diff line change 1+ package dotty .tools .pc .tests .hover
2+
3+ import dotty .tools .pc .base .BaseHoverSuite
4+
5+ import org .junit .Test
6+
7+ class HoverHoleSuite extends BaseHoverSuite :
8+ @ Test def basic =
9+ check(
10+ """ object a {
11+ | val x: Int = ?@@??
12+ |}
13+ |""" .stripMargin,
14+ """ |**Expression type**:
15+ |```scala
16+ |Int
17+ |```
18+ |**Symbol signature**:
19+ |```scala
20+ |def ???: Nothing
21+ |```
22+ |""" .stripMargin
23+ )
24+
25+ @ Test def function =
26+ check(
27+ """ object a {
28+ | def m(i: Int) = ???
29+ | val x = m(??@@?)
30+ |}
31+ |""" .stripMargin,
32+ """ |**Expression type**:
33+ |```scala
34+ |Int
35+ |```
36+ |**Symbol signature**:
37+ |```scala
38+ |def ???: Nothing
39+ |```
40+ |""" .stripMargin
41+ )
42+
43+ @ Test def constructor =
44+ check(
45+ """ object a {
46+ | val x = List(1, ?@@??)
47+ |}
48+ |""" .stripMargin,
49+ """ |**Expression type**:
50+ |```scala
51+ |Int
52+ |```
53+ |**Symbol signature**:
54+ |```scala
55+ |def ???: Nothing
56+ |```
57+ |""" .stripMargin
58+ )
59+
60+ @ Test def bounds =
61+ check(
62+ """ |trait Foo
63+ |def foo[T <: Foo](a: T): Boolean = ???
64+ |val _ = foo(?@@??)
65+ |""" .stripMargin,
66+ """ |**Expression type**:
67+ |```scala
68+ |Foo
69+ |```
70+ |**Symbol signature**:
71+ |```scala
72+ |def ???: Nothing
73+ |```
74+ |""" .stripMargin
75+ )
You can’t perform that action at this time.
0 commit comments