@@ -4380,12 +4380,11 @@ trait Types
43804380 /** Compute lub (if `variance == Covariant`) or glb (if `variance == Contravariant`) of given list
43814381 * of types `tps`. All types in `tps` are typerefs or singletypes
43824382 * with the same symbol.
4383- * Return `Some(x) ` if the computation succeeds with result `x`.
4384- * Return `None ` if the computation fails.
4383+ * Return `x ` if the computation succeeds with result `x`.
4384+ * Return `NoType ` if the computation fails.
43854385 */
4386- def mergePrefixAndArgs (tps : List [Type ], variance : Variance , depth : Int ): Option [Type ] = tps match {
4387- case List (tp) =>
4388- Some (tp)
4386+ def mergePrefixAndArgs (tps : List [Type ], variance : Variance , depth : Int ): Type = tps match {
4387+ case tp :: Nil => tp
43894388 case TypeRef (_, sym, _) :: rest =>
43904389 val pres = tps map (_.prefix) // prefix normalizes automatically
43914390 val pre = if (variance.isPositive) lub(pres, depth) else glb(pres, depth)
@@ -4397,12 +4396,13 @@ trait Types
43974396 // if argss contain one value type and some other type, the lub is Object
43984397 // if argss contain several reference types, the lub is an array over lub of argtypes
43994398 if (argss exists typeListIsEmpty) {
4400- None // something is wrong: an array without a type arg.
4401- } else {
4399+ NoType // something is wrong: an array without a type arg.
4400+ }
4401+ else {
44024402 val args = argss map (_.head)
4403- if (args.tail forall (_ =:= args.head)) Some ( typeRef(pre, sym, List (args.head) ))
4404- else if (args exists (arg => isPrimitiveValueClass(arg.typeSymbol))) Some ( ObjectTpe )
4405- else Some ( typeRef(pre, sym, List (lub(args) )))
4403+ if (args.tail forall (_ =:= args.head)) typeRef(pre, sym, List (args.head))
4404+ else if (args exists (arg => isPrimitiveValueClass(arg.typeSymbol))) ObjectTpe
4405+ else typeRef(pre, sym, List (lub(args)))
44064406 }
44074407 }
44084408 else transposeSafe(argss) match {
@@ -4411,7 +4411,7 @@ trait Types
44114411 // catching just in case (shouldn't happen, but also doesn't cost us)
44124412 // [JZ] It happens: see SI-5683.
44134413 debuglog(s " transposed irregular matrix!? tps= $tps argss= $argss" )
4414- None
4414+ NoType
44154415 case Some (argsst) =>
44164416 val args = map2(sym.typeParams, argsst) { (tparam, as0) =>
44174417 val as = as0.distinct
@@ -4442,22 +4442,22 @@ trait Types
44424442 }
44434443 }
44444444 }
4445- if (args contains NoType ) None
4446- else Some ( existentialAbstraction(capturedParams.toList, typeRef(pre, sym, args) ))
4445+ if (args contains NoType ) NoType
4446+ else existentialAbstraction(capturedParams.toList, typeRef(pre, sym, args))
44474447 }
44484448 } catch {
4449- case ex : MalformedType => None
4449+ case ex : MalformedType => NoType
44504450 }
44514451 case SingleType (_, sym) :: rest =>
44524452 val pres = tps map (_.prefix)
44534453 val pre = if (variance.isPositive) lub(pres, depth) else glb(pres, depth)
4454- try {
4455- Some (singleType(pre, sym))
4456- } catch {
4457- case ex : MalformedType => None
4458- }
4454+ try singleType(pre, sym)
4455+ catch { case ex : MalformedType => NoType }
44594456 case ExistentialType (tparams, quantified) :: rest =>
4460- mergePrefixAndArgs(quantified :: rest, variance, depth) map (existentialAbstraction(tparams, _))
4457+ mergePrefixAndArgs(quantified :: rest, variance, depth) match {
4458+ case NoType => NoType
4459+ case tpe => existentialAbstraction(tparams, tpe)
4460+ }
44614461 case _ =>
44624462 abort(s " mergePrefixAndArgs( $tps, $variance, $depth): unsupported tps " )
44634463 }
0 commit comments