Skip to content

Commit f169753

Browse files
committed
Add doc comments
1 parent 3ace887 commit f169753

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

compiler/src/dotty/tools/dotc/core/Decorators.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ object Decorators {
5858
padding + s.replace("\n", "\n" + padding)
5959
end extension
6060

61+
/** Convert lazy string to message. To be with caution, since no message-defined
62+
* formatting will be done on the string.
63+
*/
6164
extension (str: => String)
6265
def toMessage: Message = NoExplanation(str)(using NoContext)
6366

compiler/src/dotty/tools/dotc/reporting/Message.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,31 @@ end Message
208208
*
209209
* @param errorId a unique id identifying the message, this will be
210210
* used to reference documentation online
211+
*
212+
* Messages modify the rendendering of interpolated strings in several ways:
213+
*
214+
* 1. The size of the printed code is limited with a MessafeLimiter. If the message
215+
* would get too large or too deeply nested, a `...` is printed instead.
216+
* 2. References to module classes are prefixed with `object ` for better recogniability.
217+
* 3. A where clause is sometimes added which contains the following additional explanations:
218+
* - Rerences are disambiguated: If a message contains occurrences of the same identifier
219+
* representing different symbols, the duplicates are printed with superscripts
220+
* and the where-clause explains where each symbol is located.
221+
* - Uninstantiated variables are explained in the where-clause with additional
222+
* info about their bounds.
223+
* - Skolems are explained with additional info about their underlying type.
224+
*
225+
* Messages inheriting from the NoDisambiguation trait or returned from the
226+
* `noDisambiguation()` method skip point (3) above. This makes sense if the
227+
* message already exolains where different occurrences of the same identifier
228+
* are located. Examples are NamingMsgs such as double definition errors,
229+
* overriding errors, and ambiguous implicit errors.
230+
*
231+
* We consciously made the design decision to disambiguate by default and disable
232+
* disambiguation as an opt-in. The reason is that one usually does not consider all
233+
* fine-grained details when writing an error message. If disambiguation is the default,
234+
* some tests will show where clauses that look too noisy and that then can be disabled
235+
* when needed. But
211236
*/
212237
abstract class Message(val errorId: ErrorMessageID)(using Context) { self =>
213238
import Message.*

0 commit comments

Comments
 (0)