diff options
author | Paul Phillips <paulp@improving.org> | 2012-05-09 09:18:11 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-05-09 10:08:55 -0700 |
commit | e8e88f785d0020f215098450d16157e973673ba3 (patch) | |
tree | b8047970e45d6a2aaf574a71aeb4ca647d7a43fc /src | |
parent | d89ba7ff172e2f4ee12130d8caf8b9b74f581897 (diff) | |
download | scala-e8e88f785d0020f215098450d16157e973673ba3.tar.gz scala-e8e88f785d0020f215098450d16157e973673ba3.tar.bz2 scala-e8e88f785d0020f215098450d16157e973673ba3.zip |
Restored portion of code removed in a7f68ce32c .
A hole in the net discovered by retronym makes me put back the
former special casing of module class type inference; there's no
reason to get it wrong. It appears that
TypeRef(pre1, sym1, Nil)
SingleType(pre2, sym2)
are not seen as equivalent if they have different prefixes even
if the prefixes should be equivalent. For now I'm leaving it; in
principle this patch should eventually be reverted after subtyping
and/or the representation of singleton types advances to the point
that it isn't necessary. Closes SI-5777.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index fb0616c890..5534cd179c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -499,7 +499,8 @@ trait Infer { else Some( if (targ.typeSymbol == RepeatedParamClass) targ.baseType(SeqClass) else if (targ.typeSymbol == JavaRepeatedParamClass) targ.baseType(ArrayClass) - else if ((opt.experimental || opt.virtPatmat) && tvar.constr.avoidWiden) targ + // this infers Foo.type instead of "object Foo" (see also widenIfNecessary) + else if (targ.typeSymbol.isModuleClass || ((opt.experimental || opt.virtPatmat) && tvar.constr.avoidWiden)) targ else targ.widen ) )) diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 6620ef7347..063db4bb88 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -765,7 +765,10 @@ trait Namers extends MethodSynthesis { val tpe1 = dropRepeatedParamType(tpe.deconst) val tpe2 = tpe1.widen - if (sym.isVariable || sym.isMethod && !sym.hasAccessorFlag) + // This infers Foo.type instead of "object Foo" + // See Infer#adjustTypeArgs for the polymorphic case. + if (tpe.typeSymbolDirect.isModuleClass) tpe1 + else if (sym.isVariable || sym.isMethod && !sym.hasAccessorFlag) if (tpe2 <:< pt) tpe2 else tpe1 else if (isHidden(tpe)) tpe2 // In an attempt to make pattern matches involving method local vals |