@@ -928,7 +928,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
928
928
// Otherwise, if the qualifier is a context bound companion, handle
929
929
// by selecting a witness in typedCBSelect
930
930
def tryCBCompanion () =
931
- if qual.tpe.typeSymbol == defn. CBCompanion then
931
+ if qual.tpe.isContextBoundCompanion then
932
932
typedCBSelect(tree0, pt, qual)
933
933
else EmptyTree
934
934
@@ -997,13 +997,13 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
997
997
* alternatives referred to by `witnesses`.
998
998
* @param prevs a list of (ref tree, typer state, term ref) tripls that
999
999
* 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
1001
1001
* still to be considered.
1002
1002
*/
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) =>
1005
1005
tryAlts(tryAlts(prevs, wit1), wit2)
1006
- case witness : TermRef =>
1006
+ case AppliedType (_, List ( witness : TermRef )) =>
1007
1007
val altQual = tpd.ref(witness).withSpan(qual.span)
1008
1008
val altCtx = ctx.fresh.setNewTyperState()
1009
1009
val alt = typedSelectWithAdapt(tree, pt, altQual)(using altCtx)
@@ -1015,19 +1015,17 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1015
1015
if comparisons.exists(_ == 1 ) then prevs
1016
1016
else current :: prevs.zip(comparisons).collect{ case (prev, cmp) if cmp != - 1 => prev }
1017
1017
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
1031
1029
end typedCBSelect
1032
1030
1033
1031
def typedSelect (tree : untpd.Select , pt : Type )(using Context ): Tree = {
0 commit comments