From e399364ca0c3888c867f9014caeacbb6b74b7c70 Mon Sep 17 00:00:00 2001 From: aherlihy Date: Mon, 10 Feb 2025 13:46:52 +0100 Subject: [PATCH] Add warning for :kind command --- compiler/src/dotty/tools/repl/ParseResult.scala | 8 ++++++++ compiler/src/dotty/tools/repl/ReplDriver.scala | 4 ++++ compiler/test-resources/repl/i21655 | 2 ++ compiler/test/dotty/tools/repl/TabcompleteTests.scala | 1 + 4 files changed, 15 insertions(+) create mode 100644 compiler/test-resources/repl/i21655 diff --git a/compiler/src/dotty/tools/repl/ParseResult.scala b/compiler/src/dotty/tools/repl/ParseResult.scala index 6c9f95d4dca2..2674a385a10c 100644 --- a/compiler/src/dotty/tools/repl/ParseResult.scala +++ b/compiler/src/dotty/tools/repl/ParseResult.scala @@ -52,6 +52,13 @@ object Load { val command: String = ":load" } +/** `:kind ` display the kind of a type. see also :help kind + */ +case class KindOf(expr: String) extends Command +object KindOf { + val command: String = ":kind" +} + /** To find out the type of an expression you may simply do: * * ``` @@ -138,6 +145,7 @@ object ParseResult { Help.command -> (_ => Help), Reset.command -> (arg => Reset(arg)), Imports.command -> (_ => Imports), + KindOf.command -> (arg => KindOf(arg)), Load.command -> (arg => Load(arg)), TypeOf.command -> (arg => TypeOf(arg)), DocOf.command -> (arg => DocOf(arg)), diff --git a/compiler/src/dotty/tools/repl/ReplDriver.scala b/compiler/src/dotty/tools/repl/ReplDriver.scala index 96aa31b8753b..0f2921fd736c 100644 --- a/compiler/src/dotty/tools/repl/ReplDriver.scala +++ b/compiler/src/dotty/tools/repl/ReplDriver.scala @@ -510,6 +510,10 @@ class ReplDriver(settings: Array[String], state } + case KindOf(expr) => + out.println(s"""The :kind command is not currently supported.""") + state + case TypeOf(expr) => expr match { case "" => out.println(s":type ") diff --git a/compiler/test-resources/repl/i21655 b/compiler/test-resources/repl/i21655 new file mode 100644 index 000000000000..57b09bfad32d --- /dev/null +++ b/compiler/test-resources/repl/i21655 @@ -0,0 +1,2 @@ +scala>:kind +The :kind command is not currently supported. \ No newline at end of file diff --git a/compiler/test/dotty/tools/repl/TabcompleteTests.scala b/compiler/test/dotty/tools/repl/TabcompleteTests.scala index 01b9d1109994..66c0fd8a9ce7 100644 --- a/compiler/test/dotty/tools/repl/TabcompleteTests.scala +++ b/compiler/test/dotty/tools/repl/TabcompleteTests.scala @@ -213,6 +213,7 @@ class TabcompleteTests extends ReplTest { ":exit", ":help", ":imports", + ":kind", ":load", ":quit", ":reset",