@@ -928,7 +928,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
928928 // Otherwise, if the qualifier is a context bound companion, handle
929929 // by selecting a witness in typedCBSelect
930930 def tryCBCompanion () =
931- if qual.tpe.typeSymbol == defn. CBCompanion then
931+ if qual.tpe.isContextBoundCompanion then
932932 typedCBSelect(tree0, pt, qual)
933933 else EmptyTree
934934
@@ -997,13 +997,13 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
997997 * alternatives referred to by `witnesses`.
998998 * @param prevs a list of (ref tree, typer state, term ref) tripls that
999999 * represents previously identified alternatives
1000- * @param witnesses a type of the form ref_1 | ... | ref_n containing references
1000+ * @param witnesses a type of the form `isContextBoundCompanion` containing references
10011001 * still to be considered.
10021002 */
1003- def tryAlts (prevs : Alts , witnesses : Type ): Alts = witnesses match
1004- case OrType (wit1, wit2) =>
1003+ def tryAlts (prevs : Alts , witnesses : Type ): Alts = witnesses.widen match
1004+ case AndType (wit1, wit2) =>
10051005 tryAlts(tryAlts(prevs, wit1), wit2)
1006- case witness : TermRef =>
1006+ case AppliedType (_, List ( witness : TermRef )) =>
10071007 val altQual = tpd.ref(witness).withSpan(qual.span)
10081008 val altCtx = ctx.fresh.setNewTyperState()
10091009 val alt = typedSelectWithAdapt(tree, pt, altQual)(using altCtx)
@@ -1015,19 +1015,17 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
10151015 if comparisons.exists(_ == 1 ) then prevs
10161016 else current :: prevs.zip(comparisons).collect{ case (prev, cmp) if cmp != - 1 => prev }
10171017
1018- qual.tpe.widen match
1019- case AppliedType (_, arg :: Nil ) =>
1020- tryAlts(Nil , arg) match
1021- case Nil => EmptyTree
1022- case (best @ (bestTree, bestState, _)) :: Nil =>
1023- bestState.commit()
1024- bestTree
1025- case multiAlts =>
1026- report.error(
1027- em """ Ambiguous witness reference. None of the following alternatives is more specific than the other:
1028- | ${multiAlts.map((alt, _, witness) => i " \n $witness. ${tree.name}: ${alt.tpe.widen}" )}""" ,
1029- tree.srcPos)
1030- EmptyTree
1018+ tryAlts(Nil , qual.tpe) match
1019+ case Nil => EmptyTree
1020+ case (best @ (bestTree, bestState, _)) :: Nil =>
1021+ bestState.commit()
1022+ bestTree
1023+ case multiAlts =>
1024+ report.error(
1025+ em """ Ambiguous witness reference. None of the following alternatives is more specific than the other:
1026+ | ${multiAlts.map((alt, _, witness) => i " \n $witness. ${tree.name}: ${alt.tpe.widen}" )}""" ,
1027+ tree.srcPos)
1028+ EmptyTree
10311029 end typedCBSelect
10321030
10331031 def typedSelect (tree : untpd.Select , pt : Type )(using Context ): Tree = {
0 commit comments