summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-02-18 22:03:28 +0000
committerPaul Phillips <paulp@improving.org>2009-02-18 22:03:28 +0000
commita626f6253829d0c8512551e8ae1290511cb077f1 (patch)
tree51e9e0e20d1279bbde2a5841ccdf3d9a6f016218 /src/compiler
parent36b0e8178f74a2986bce5c9027b9a2b22a4e7527 (diff)
downloadscala-a626f6253829d0c8512551e8ae1290511cb077f1.tar.gz
scala-a626f6253829d0c8512551e8ae1290511cb077f1.tar.bz2
scala-a626f6253829d0c8512551e8ae1290511cb077f1.zip
Issue warning when attempting to refine Unit, p...
Issue warning when attempting to refine Unit, plus test case; bug #284.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index b8b8d1bffb..e4a042325c 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -796,8 +796,18 @@ trait Parsers extends NewScanners with MarkupParsers {
}
newLineOptWhenFollowedBy(LBRACE)
atPos(pos) {
- if (inToken == LBRACE)
+ if (inToken == LBRACE) {
+ // Warn if they are attempting to refine Unit; we can't be certain it's
+ // scala.Unit they're refining because at this point all we have is an
+ // identifier, but at a later stage we lose the ability to tell an empty
+ // refinement from no refinement at all. See bug #284.
+ for (Ident(name) <- ts) name.toString match {
+ case "Unit" | "scala.Unit" =>
+ warning("Detected apparent refinement of Unit; are you missing an '=' sign?")
+ case _ =>
+ }
CompoundTypeTree(Template(ts.toList, emptyValDef, refinement()))
+ }
else
makeIntersectionTypeTree(ts.toList)
}