Skip to content

Commit 01ae042

Browse files
committed
Refactor isStructural condition
1 parent 2c33887 commit 01ae042

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,8 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
864864
* that is not a member of an underlying class or trait?
865865
*/
866866
def isStructuralTermSelectOrApply(tree: Tree)(using Context): Boolean = {
867-
def isStructuralTermSelect(tree: Select) = {
868-
def hasRefinement(qualtpe: Type): Boolean = qualtpe.dealias match {
867+
def isStructuralTermSelect(tree: Select) =
868+
def hasRefinement(qualtpe: Type): Boolean = qualtpe.dealias match
869869
case RefinedType(parent, rname, rinfo) =>
870870
rname == tree.name || hasRefinement(parent)
871871
case tp: TypeProxy =>
@@ -876,11 +876,12 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
876876
hasRefinement(tp.tp1) || hasRefinement(tp.tp2)
877877
case _ =>
878878
false
879-
}
880879
!tree.symbol.exists
881-
&& !tree.qualifier.tpe.widen.derivesFrom(defn.PolyFunctionClass)
882-
&& tree.isTerm && hasRefinement(tree.qualifier.tpe)
883-
}
880+
&& tree.isTerm
881+
&& {
882+
val qualType = tree.qualifier.tpe
883+
hasRefinement(qualType) && !qualType.derivesFrom(defn.PolyFunctionClass)
884+
}
884885
def loop(tree: Tree): Boolean = tree match
885886
case TypeApply(fun, _) =>
886887
loop(fun)

0 commit comments

Comments
 (0)