Skip to content

Commit 08d4d59

Browse files
committed
Introduce hasAltWithInline, to fix all usages
1 parent e570a90 commit 08d4d59

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

compiler/src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ object Denotations {
261261
/** Does this denotation have an alternative that satisfies the predicate `p`? */
262262
def hasAltWith(p: SingleDenotation => Boolean): Boolean
263263

264+
inline final def hasAltWithInline(inline p: SingleDenotation => Boolean): Boolean = inline this match
265+
case mbr: SingleDenotation => mbr.exists && p(mbr)
266+
case mbr => mbr.hasAltWith(p)
267+
264268
/** The denotation made up from the alternatives of this denotation that
265269
* are accessible from prefix `pre`, or NoDenotation if no accessible alternative exists.
266270
*/

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,9 +2020,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
20202020
|| matchAbstractTypeMember(m.info)
20212021
|| (tp1.isStable && isSubType(TermRef(tp1, m.symbol), tp2.refinedInfo))
20222022

2023-
tp1.member(name) match // inlined hasAltWith for performance
2024-
case mbr: SingleDenotation => mbr.exists && qualifies(mbr)
2025-
case mbr => mbr hasAltWith qualifies
2023+
tp1.member(name).hasAltWithInline(qualifies)
20262024
}
20272025

20282026
final def ensureStableSingleton(tp: Type): SingletonType = tp.stripTypeVar match {

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,10 +1519,7 @@ trait Applications extends Compatibility {
15191519
&& isApplicableType(
15201520
normalize(tp.select(xname, mbr), WildcardType),
15211521
argType :: Nil, resultType)
1522-
tp.memberBasedOnFlags(xname, required = ExtensionMethod) match {
1523-
case mbr: SingleDenotation => qualifies(mbr)
1524-
case mbr => mbr.hasAltWith(qualifies(_))
1525-
}
1522+
tp.memberBasedOnFlags(xname, required = ExtensionMethod).hasAltWithInline(qualifies)
15261523
}
15271524

15281525
/** Drop any leading type or implicit parameter sections */

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@ object ProtoTypes {
211211
|| tp1.isValueType && compat.normalizedCompatible(NamedType(tp1, name, m), memberProto, keepConstraint))
212212
// Note: can't use `m.info` here because if `m` is a method, `m.info`
213213
// loses knowledge about `m`'s default arguments.
214-
mbr match // hasAltWith inlined for performance
215-
case mbr: SingleDenotation => mbr.exists && qualifies(mbr)
216-
case _ => mbr hasAltWith qualifies
214+
mbr.hasAltWithInline(qualifies)
217215
catch case ex: TypeError =>
218216
// A scenario where this can happen is in pos/15673.scala:
219217
// We have a type `CC[A]#C` where `CC`'s upper bound is `[X] => Any`, but

0 commit comments

Comments
 (0)