summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-06-01 05:15:49 +0000
committerPaul Phillips <paulp@improving.org>2011-06-01 05:15:49 +0000
commitd838e10f7bad42762584a1390ef6fd85b4796d46 (patch)
tree03c37de5fcf1cc01746a3564a378947e1b71891b /src
parent46c81507437d3202826e2ab53f328b241a6c9387 (diff)
downloadscala-d838e10f7bad42762584a1390ef6fd85b4796d46.tar.gz
scala-d838e10f7bad42762584a1390ef6fd85b4796d46.tar.bz2
scala-d838e10f7bad42762584a1390ef6fd85b4796d46.zip
The eagerly awaited companion commit to r23622,...
The eagerly awaited companion commit to r23622, the surprise hit of last winter. Singletons now have the singleton type inferred in monomorphic contexts as well. In english: scala> object X defined module X scala> def f = X f: X.type Wait, that's not english. English review by moors.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala7
2 files changed, 7 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 88cecbd402..1bd2487089 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -572,7 +572,7 @@ trait Infer {
tparam -> Some(
if (targ.typeSymbol == RepeatedParamClass) targ.baseType(SeqClass)
else if (targ.typeSymbol == JavaRepeatedParamClass) targ.baseType(ArrayClass)
- else if (targ.typeSymbol.isModuleClass) targ // this infers Foo.type instead of "object Foo"
+ else if (targ.typeSymbol.isModuleClass) targ // this infers Foo.type instead of "object Foo" (see also widenIfNecessary)
else targ.widen
)
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index c5f32a344f..fddf115730 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -630,9 +630,14 @@ trait Namers { self: Analyzer =>
case _ =>
false
}
+
val tpe1 = 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