@@ -82,21 +82,25 @@ class VarianceChecker()(implicit ctx: Context) {
8282 * same is true of the parameters (ValDefs).
8383 */
8484 def apply (status : Option [VarianceError ], tp : Type ): Option [VarianceError ] = trace(s " variance checking $tp of $base at $variance" , variances) {
85- if (status.isDefined) status
86- else tp match {
87- case tp : TypeRef =>
88- val sym = tp.symbol
89- if (sym.variance != 0 && base.isContainedIn(sym.owner)) checkVarianceOfSymbol(sym)
90- else if (sym.isAliasType) this (status, sym.info.bounds.hi)
91- else foldOver(status, tp)
92- case tp : MethodOrPoly =>
93- this (status, tp.resultType) // params will be checked in their TypeDef or ValDef nodes.
94- case AnnotatedType (_, annot) if annot.symbol == defn.UncheckedVarianceAnnot =>
95- status
96- // case tp: ClassInfo =>
97- // ??? not clear what to do here yet. presumably, it's all checked at local typedefs
98- case _ =>
99- foldOver(status, tp)
85+ try
86+ if (status.isDefined) status
87+ else tp match {
88+ case tp : TypeRef =>
89+ val sym = tp.symbol
90+ if (sym.variance != 0 && base.isContainedIn(sym.owner)) checkVarianceOfSymbol(sym)
91+ else if (sym.isAliasType) this (status, sym.info.bounds.hi)
92+ else foldOver(status, tp)
93+ case tp : MethodOrPoly =>
94+ this (status, tp.resultType) // params will be checked in their TypeDef or ValDef nodes.
95+ case AnnotatedType (_, annot) if annot.symbol == defn.UncheckedVarianceAnnot =>
96+ status
97+ // case tp: ClassInfo =>
98+ // ??? not clear what to do here yet. presumably, it's all checked at local typedefs
99+ case _ =>
100+ foldOver(status, tp)
101+ }
102+ catch {
103+ case ex : Throwable => handleRecursive(" variance check of" , tp.show, ex)
100104 }
101105 }
102106
0 commit comments