diff options
author | Paul Phillips <paulp@improving.org> | 2012-02-28 09:16:03 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-02-28 09:49:02 -0800 |
commit | c11ec6f532449f110c3b776b11f0b2c4398fe0f9 (patch) | |
tree | 0e5a5f13dfa53d7cdc093099b3dfe46063ae4409 /src/compiler/scala/tools/nsc/typechecker/Typers.scala | |
parent | f3711b634ccfa6ef4ab14ffc8d12d244de6917c2 (diff) | |
download | scala-c11ec6f532449f110c3b776b11f0b2c4398fe0f9.tar.gz scala-c11ec6f532449f110c3b776b11f0b2c4398fe0f9.tar.bz2 scala-c11ec6f532449f110c3b776b11f0b2c4398fe0f9.zip |
Fix for typing of objects in patterns.
An object in a pattern should have type "Foo.type" just as
objects not in patterns do. Closes SI-5406. Review by @moors.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index ea8112f1a4..0a1a385846 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -614,7 +614,12 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { if (tree.isErrorTyped) tree else if ((mode & (PATTERNmode | FUNmode)) == PATTERNmode && tree.isTerm) { // (1) - if (sym.isValue) checkStable(tree) + if (sym.isValue) { + val tree1 = checkStable(tree) + // A module reference in a pattern has type Foo.type, not "object Foo" + if (sym.isModule && !sym.isMethod) tree1 setType singleType(pre, sym) + else tree1 + } else fail() } else if ((mode & (EXPRmode | QUALmode)) == EXPRmode && !sym.isValue && !phase.erasedTypes) { // (2) fail() |