summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-07-13 05:08:12 +0000
committerPaul Phillips <paulp@improving.org>2011-07-13 05:08:12 +0000
commite032852d12a301fb8ee8b10fe1f6a6f6eb09b7d4 (patch)
treef77a759ad5667e358fc91102b76704fd40a0d217 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parentcda484779f3de0ca59aff243326f5a414e63b946 (diff)
downloadscala-e032852d12a301fb8ee8b10fe1f6a6f6eb09b7d4.tar.gz
scala-e032852d12a301fb8ee8b10fe1f6a6f6eb09b7d4.tar.bz2
scala-e032852d12a301fb8ee8b10fe1f6a6f6eb09b7d4.zip
Catch type projections even when they disguise ...
Catch type projections even when they disguise themselves as stable via singleton bounds. Closes #1431, review by odersky.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 023f170c4b..5bbc0b6430 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -223,15 +223,24 @@ trait Typers extends Modes {
/** Check that `tpt` refers to a non-refinement class type */
def checkClassType(tpt: Tree, existentialOK: Boolean, stablePrefix: Boolean) {
+ def errorNotClass(found: AnyRef) = error(tpt.pos, "class type required but "+found+" found")
def check(tpe: Type): Unit = tpe.normalize match {
case TypeRef(pre, sym, _) if sym.isClass && !sym.isRefinementClass =>
- if (stablePrefix && phase.id <= currentRun.typerPhase.id && !pre.isStable)
- error(tpt.pos, "type "+pre+" is not a stable prefix")
+ if (stablePrefix && phase.id <= currentRun.typerPhase.id) {
+ if (!pre.isStable)
+ error(tpt.pos, "type "+pre+" is not a stable prefix")
+ // A type projection like X#Y can get by the stable check if the
+ // prefix is singleton-bounded, so peek at the tree too.
+ else tpt match {
+ case SelectFromTypeTree(qual, _) if !isSingleType(qual.tpe) => errorNotClass(tpt)
+ case _ => ;
+ }
+ }
case ErrorType => ;
case PolyType(_, restpe) => check(restpe)
case ExistentialType(_, restpe) if existentialOK => check(restpe)
case AnnotatedType(_, underlying, _) => check(underlying)
- case t => error(tpt.pos, "class type required but "+t+" found")
+ case t => errorNotClass(t)
}
check(tpt.tpe)
}