diff options
author | Paul Phillips <paulp@improving.org> | 2012-08-31 08:41:55 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-08-31 16:57:18 -0700 |
commit | 1a32068e08c54249a1a2317ca321e7984edd2b96 (patch) | |
tree | cf14c502d68b32c5fcd67e12eb8abae373547c83 /src/compiler/scala/tools/nsc/typechecker/Typers.scala | |
parent | c4e055c02125ebdcb91b7231f19995bb9dec0fd7 (diff) | |
download | scala-1a32068e08c54249a1a2317ca321e7984edd2b96.tar.gz scala-1a32068e08c54249a1a2317ca321e7984edd2b96.tar.bz2 scala-1a32068e08c54249a1a2317ca321e7984edd2b96.zip |
Warn when overloaded types are seen after typer.
Since it almost invariably means a crash is coming.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 1770f2419a..f8826dc27f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -4503,6 +4503,31 @@ trait Typers extends Modes with Adaptations with Tags { * @return ... */ def typedSelect(tree: Tree, qual: Tree, name: Name): Tree = { + val t = typedSelectInternal(tree, qual, name) + if (isPastTyper) t.tpe match { + case OverloadedType(pre, alts) => + if (alts forall (s => (s.owner == ObjectClass) || (s.owner == AnyClass) || isPrimitiveValueClass(s.owner))) () + else { + val msg = + s"""|Select received overloaded type during $phase, but typer is over. + |We are likely doomed to crash in the backend. + |$t has these overloads: + |${alts map (s => " " + s.defStringSeenAs(pre memberType s)) mkString "\n"} + |""".stripMargin + + if (context.reportErrors) + unit.warning(t.pos, msg) + else + Console.err.println(msg) + + if (settings.debug.value) + (new Throwable).printStackTrace + } + case _ => + } + t + } + def typedSelectInternal(tree: Tree, qual: Tree, name: Name): Tree = { def asDynamicCall = dyna.mkInvoke(context.tree, tree, qual, name) map (typed1(_, mode, pt)) val sym = tree.symbol orElse member(qual, name) orElse { |