File tree 2 files changed +76
-1
lines changed
test/dotty/tools/pc/tests/hover
2 files changed +76
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ import dotty.tools.dotc.util.SourcePosition
25
25
import dotty .tools .pc .printer .ShortenedTypePrinter
26
26
import dotty .tools .pc .printer .ShortenedTypePrinter .IncludeDefaultParam
27
27
import dotty .tools .pc .utils .InteractiveEnrichments .*
28
+ import dotty .tools .dotc .ast .untpd .InferredTypeTree
29
+ import dotty .tools .dotc .core .StdNames
28
30
29
31
object HoverProvider :
30
32
@@ -131,7 +133,12 @@ object HoverProvider:
131
133
.flatMap(symTpe => search.symbolDocumentation(symTpe._1, contentType))
132
134
.map(_.docstring())
133
135
.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
135
142
case Some (expressionType) =>
136
143
val forceExpressionType =
137
144
! 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[Int] = List(?@@??)
47
+ |}
48
+ |""" .stripMargin,
49
+ """ |def ???: Nothing
50
+ |""" .stripMargin.hover
51
+ )
52
+
53
+ @ Test def bounds =
54
+ check(
55
+ """ |trait Foo
56
+ |def foo[T <: Foo](a: T): Boolean = ???
57
+ |val _ = foo(?@@??)
58
+ |""" .stripMargin,
59
+ """ |**Expression type**:
60
+ |```scala
61
+ |Foo
62
+ |```
63
+ |**Symbol signature**:
64
+ |```scala
65
+ |def ???: Nothing
66
+ |```
67
+ |""" .stripMargin
68
+ )
You can’t perform that action at this time.
0 commit comments