diff options
Diffstat (limited to 'src')
4 files changed, 9 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 0835a1b2d0..3322a5a28f 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -77,7 +77,9 @@ trait Scanners extends ScannersCommon { def resume(lastCode: Int) = { token = lastCode - assert(next.token == EMPTY || reporter.hasErrors) + if (next.token != EMPTY && !reporter.hasErrors) + syntaxError("unexpected end of input: possible missing '}' in XML block") + nextToken() } diff --git a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala index b1be70a54c..2754a7b113 100644 --- a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala +++ b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala @@ -581,16 +581,10 @@ abstract class ScalaPrimitives { val code = getPrimitive(fun) def elementType = atPhase(currentRun.typerPhase) { - val arrayParent = tpe :: tpe.parents find { - case TypeRef(_, sym, _elem :: Nil) - if (sym == ArrayClass) => true - case _ => false + val arrayParent = tpe :: tpe.parents collectFirst { + case TypeRef(_, ArrayClass, elem :: Nil) => elem } - if (arrayParent.isEmpty) { - println(fun.fullName + " : " + tpe :: tpe.baseTypeSeq.toList) - } - val TypeRef(_, _, elem :: Nil) = arrayParent.get - elem + arrayParent getOrElse system.error(fun.fullName + " : " + (tpe :: tpe.baseTypeSeq.toList).mkString(", ")) } code match { diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 1c39e582df..ee0a0c4d81 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -349,10 +349,7 @@ trait Definitions extends reflect.generic.StandardDefinitions { /** if tpe <: ProductN[T1,...,TN], returns Some(T1,...,TN) else None */ def getProductArgs(tpe: Type): Option[List[Type]] = - tpe.baseClasses.find(x => isExactProductType(x.tpe)) match { - case Some(p) => Some(tpe.baseType(p).typeArgs) - case _ => None - } + tpe.baseClasses collectFirst { case x if isExactProductType(x.tpe) => tpe.baseType(x).typeArgs } def unapplyUnwrap(tpe:Type) = (tpe match { case PolyType(_,MethodType(_, res)) => res diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 5d19d469b5..c2110f104d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -38,10 +38,8 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT private var validCurrentOwner = true private var accDefs: List[(Symbol, ListBuffer[Tree])] = List() - private def accDefBuf(clazz: Symbol) = accDefs find (_._1 == clazz) match { - case Some((_, buf)) => buf - case None => throw new AssertionError("no acc def buf for "+clazz) - } + private def accDefBuf(clazz: Symbol) = + accDefs collectFirst { case (`clazz`, buf) => buf } getOrElse system.error("no acc def buf for "+clazz) private def transformArgs(args: List[Tree], params: List[Symbol]) = ((args, params).zipped map { (arg, param) => |