aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/typer/RefChecks.scala2
-rw-r--r--tests/neg/i1992.scala9
3 files changed, 11 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
index 94611e10d..9318ad8c6 100644
--- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
+++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
@@ -1055,7 +1055,7 @@ object messages {
|
|Define `${definition.name}` before it is used,
|or move the definition of `${value.name}` so it does not appear between
- |the declartion of `${definition.name}` and its use,
+ |the declaration of `${definition.name}` and its use,
|or define `${value.name}` as lazy.
|""".stripMargin
}
diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
index eab91701b..7c573d23c 100644
--- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
+++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
@@ -789,7 +789,7 @@ class RefChecks extends MiniPhase { thisTransformer =>
val sym = tree.symbol
if (sym.exists && sym.owner.isTerm && !sym.is(Lazy))
currentLevel.levelAndIndex.get(sym) match {
- case Some((level, symIdx)) if symIdx < level.maxIndex =>
+ case Some((level, symIdx)) if symIdx <= level.maxIndex =>
ctx.error(ForwardReferenceExtendsOverDefinition(sym, level.refSym), level.refPos)
case _ =>
}
diff --git a/tests/neg/i1992.scala b/tests/neg/i1992.scala
new file mode 100644
index 000000000..818b46771
--- /dev/null
+++ b/tests/neg/i1992.scala
@@ -0,0 +1,9 @@
+object Test {
+ def main(args: Array[String]) = {
+ val x: Int => Unit =
+ y => println(x) // error: `x` is a forward reference
+ implicit val z: String => Unit =
+ y => println(implicitly[String => Unit]) // error: `z` is a forward reference
+ }
+}
+