From 1bff5703d28a0232dc772769dd6017862114a4a2 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 10 May 2012 13:44:29 -0700 Subject: More useful crash reports. If you can't get your hands on something which crashes scalac - I know, I know - you can try this ready-made crasher. % cat test/pending/pos/t4717.scala trait Bounds[@specialized A] { // okay without `>: A` def x[B >: A]: Unit = new Bounds[B] { lazy val it = ??? // def or val okay it } } % scalac -d /tmp test/pending/pos/t4717.scala error: while compiling: test/pending/pos/t4717.scala during phase: specialize library version: version 2.10.0-20120510-134429-ce1d68ed19 compiler version: version 2.10.0-20120510-152646-ba4dfd1e63 reconstructed args: -d /tmp last tree to typer: Select(This(trait Bounds$mcZ$sp), x$mcZ$sp) symbol: method x$mcZ$sp in trait Bounds$mcZ$sp (flags: override ) symbol definition: override def x$mcZ$sp[B >: Boolean](): Unit tpe: [B >: Boolean]()Unit symbol owners: method x$mcZ$sp -> trait Bounds$mcZ$sp -> package context owners: value it -> anonymous class $anon -> method x$mcZ$sp -> trait Bounds$mcZ$sp -> package == Enclosing template or block == Block( Assign( $anon.this."it " Apply( // def ???(): Nothing in object Predef, tree.tpe=Nothing scala.this."Predef"."$qmark$qmark$qmark" // def ???(): Nothing in object Predef, tree.tpe=()Nothing Nil ) ) $anon.this."it " // lazy private[this] var it: Nothing, tree.tpe=Nothing ) == Expanded type of tree == PolyType( typeParams = List(TypeParam(B >: Boolean)) resultType = NullaryMethodType( resultType = TypeRef(TypeSymbol(final class Unit extends AnyVal)) ) ) // And then the usual stack trace --- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala') diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 343636ff1e..34e1aaedfd 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -31,7 +31,6 @@ trait Typers extends Modes with Adaptations with Taggings { import global._ import definitions._ - import patmat.DefaultOverrideMatchAttachment final def forArgMode(fun: Tree, mode: Int) = @@ -85,6 +84,12 @@ trait Typers extends Modes with Adaptations with Taggings { private def isPastTyper = phase.id > currentRun.typerPhase.id + // To enable decent error messages when the typer crashes. + // TODO - this only catches trees which go through def typed, + // but there are all kinds of back ways - typedClassDef, etc. etc. + // Funnel everything through one doorway. + var lastTreeToTyper: Tree = EmptyTree + // when true: // - we may virtualize matches (if -Xexperimental and there's a suitable __match in scope) // - we synthesize PartialFunction implementations for `x => x match {...}` and `match {...}` when the expected type is PartialFunction @@ -4972,6 +4977,7 @@ trait Typers extends Modes with Adaptations with Taggings { * @return ... */ def typed(tree: Tree, mode: Int, pt: Type): Tree = { + lastTreeToTyper = tree indentTyping() var alreadyTyped = false -- cgit v1.2.3