Skip to content

Commit c2079f2

Browse files
committed
Annotate isAsSpecific with references to its documentation
Also reorder the cases to be in the same order as the documentation.
1 parent 7d76151 commit c2079f2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -863,10 +863,7 @@ trait Applications extends Compatibility { self: Typer =>
863863
* with `tp2`.
864864
*/
865865
def isAsSpecific(alt1: TermRef, tp1: Type, alt2: TermRef, tp2: Type): Boolean = ctx.traceIndented(i"isAsSpecific $tp1 $tp2", overload) { tp1 match {
866-
case tp1: PolyType =>
867-
val tparams = ctx.newTypeParams(alt1.symbol, tp1.paramNames, EmptyFlags, tp1.instantiateBounds)
868-
isAsSpecific(alt1, tp1.instantiate(tparams map (_.typeRef)), alt2, tp2)
869-
case tp1: MethodType =>
866+
case tp1: MethodType => // (1)
870867
def repeatedToSingle(tp: Type): Type = tp match {
871868
case tp @ ExprType(tp1) => tp.derivedExprType(repeatedToSingle(tp1))
872869
case _ => if (tp.isRepeatedParam) tp.argTypesHi.head else tp
@@ -876,18 +873,21 @@ trait Applications extends Compatibility { self: Typer =>
876873
else tp1.paramTypes
877874
isApplicable(alt2, formals1, WildcardType) ||
878875
tp1.paramTypes.isEmpty && tp2.isInstanceOf[MethodOrPoly]
879-
case _ =>
876+
case tp1: PolyType => // (2)
877+
val tparams = ctx.newTypeParams(alt1.symbol, tp1.paramNames, EmptyFlags, tp1.instantiateBounds)
878+
isAsSpecific(alt1, tp1.instantiate(tparams map (_.typeRef)), alt2, tp2)
879+
case _ => // (3)
880880
tp2 match {
881-
case tp2: MethodType => true
882-
case tp2: PolyType if tp2.isPolymorphicMethodType => true
883-
case tp2: PolyType =>
881+
case tp2: MethodType => true // (3a)
882+
case tp2: PolyType if tp2.isPolymorphicMethodType => true // (3a)
883+
case tp2: PolyType => // (3b)
884884
val nestedCtx = ctx.fresh.setExploreTyperState
885885

886886
{
887887
implicit val ctx: Context = nestedCtx
888888
isCompatible(tp1, constrained(tp2).resultType)
889889
}
890-
case _ =>
890+
case _ => // (3b)
891891
isCompatible(tp1, tp2)
892892
}
893893
}}

0 commit comments

Comments
 (0)