diff options
author | Jonathan Brachthäuser <jonathan@b-studios.de> | 2017-01-07 16:25:11 +0100 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2017-01-08 20:11:15 +0100 |
commit | 42227a61e1a9cbdb9bfdc8cf2e99e3f675f9994e (patch) | |
tree | 5b128ca960da58ce57e75254783c66198e2c2867 | |
parent | 966f1b8a6d9954a01f3a2aaeb3d9accd747ee879 (diff) | |
download | dotty-42227a61e1a9cbdb9bfdc8cf2e99e3f675f9994e.tar.gz dotty-42227a61e1a9cbdb9bfdc8cf2e99e3f675f9994e.tar.bz2 dotty-42227a61e1a9cbdb9bfdc8cf2e99e3f675f9994e.zip |
Give context for code examples to ease understanding
-rw-r--r-- | compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 9ba771be9..89cd2cd8f 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -971,25 +971,34 @@ object messages { val kind = "Syntax" val msg = hl"""Expected an additional member selection after the keyword ${"this"}""" + val contextCode = + """ trait Outer { + | val member: Int + | type Member + | trait Inner { + | ... + | } + | }""" + val importCode = - """import MyClass.this.member - |// ^^^^^^^ - """ + """ import Outer.this.member + | // ^^^^^^^""" val typeCode = - """type T = MyClass.this.Member - |// ^^^^^^^ - """ + """ type T = Outer.this.Member + | // ^^^^^^^""" val explanation = hl"""|Paths of imports and type selections must not end with the keyword ${"this"}. | - |Maybe you forgot to select a member of ${"this"}? + |Maybe you forgot to select a member of ${"this"}? As an example, in the + |following context: + |${contextCode} | - |- Example for a valid import expression using a path + |- this is a valid import expression using a path |${importCode} | - |- Example for a valid type using a path + |- this is a valid type using a path |${typeCode} |""" } |