Skip to content

Commit 82ae5cc

Browse files
committed
fix(#11202): explicitly handle TypeTree in syntax highlighting
1 parent 29f9d33 commit 82ae5cc

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ object SyntaxHighlighting {
112112
highlightPosition(tree.nameSpan, TypeColor)
113113
case tree: Ident if tree.isType =>
114114
highlightPosition(tree.span, TypeColor)
115-
case _: TypTree =>
115+
case _: TypeTree =>
116116
highlightPosition(tree.span, TypeColor)
117117
case _ =>
118118
}

compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ class SyntaxHighlightingTests extends DottyTest {
2323

2424
if (expected != highlighted) {
2525
// assertEquals produces weird expected/found message
26-
fail(s"expected: $expected but was: $highlighted")
26+
fail(s"""|
27+
|expected: $expected
28+
|highlighted: $highlighted""".stripMargin)
2729
}
2830
}
2931

@@ -41,6 +43,8 @@ class SyntaxHighlightingTests extends DottyTest {
4143
test("type Foo = Int", "<K|type> <T|Foo> = <T|Int>")
4244
test("type A = String | Int", "<K|type> <T|A> = <T|String> <T||> <T|Int>")
4345
test("type B = String & Int", "<K|type> <T|B> = <T|String> <T|&> <T|Int>")
46+
test("type Id[A] = A", "<K|type> <T|Id>[<T|A>] = <T|A>")
47+
test("type Foo = [X] =>> List[X]", "<K|type> <T|Foo> = [<T|X>] =>> <T|List>[<T|X>]")
4448
}
4549

4650
@Test
@@ -111,7 +115,7 @@ class SyntaxHighlightingTests extends DottyTest {
111115
test("def f1(x: Int) = 123", "<K|def> <V|f1>(<V|x>: <T|Int>) = <L|123>")
112116
test("def f2[T](x: T) = { 123 }", "<K|def> <V|f2>[<T|T>](<V|x>: <T|T>) = { <L|123> }")
113117

114-
test("def f3[T[_", "<K|def> <V|f3>[<T|T>[<T|_>")
118+
test("def f3[T[_", "<K|def> <V|f3>[<T|T>[_")
115119
}
116120

117121
@Test

0 commit comments

Comments
 (0)