Skip to content

Commit 4f3d767

Browse files
authored
Merge pull request #14518 from ckipp01/lambdaTypeTreeHighlighting
fix(#11202): special case type trees in syntax highlighting
2 parents 72acaef + b1e4267 commit 4f3d767

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-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: 10 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
@@ -88,6 +92,10 @@ class SyntaxHighlightingTests extends DottyTest {
8892
test("val foo", "<K|val> <V|foo>")
8993
test("val foo =", "<K|val> <V|foo> =")
9094
test("val foo = 123", "<K|val> <V|foo> = <L|123>")
95+
test(
96+
"val foo: List[List[Int]] = List(List(1))",
97+
"<K|val> <V|foo>: <T|List>[<T|List>[<T|Int>]] = List(List(<L|1>))"
98+
)
9199

92100
test("var", "<K|var>")
93101
test("var foo", "<K|var> <V|foo>")
@@ -111,7 +119,7 @@ class SyntaxHighlightingTests extends DottyTest {
111119
test("def f1(x: Int) = 123", "<K|def> <V|f1>(<V|x>: <T|Int>) = <L|123>")
112120
test("def f2[T](x: T) = { 123 }", "<K|def> <V|f2>[<T|T>](<V|x>: <T|T>) = { <L|123> }")
113121

114-
test("def f3[T[_", "<K|def> <V|f3>[<T|T>[<T|_>")
122+
test("def f3[T[_", "<K|def> <V|f3>[<T|T>[_")
115123
}
116124

117125
@Test

0 commit comments

Comments
 (0)