aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/ast
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2017-02-01 18:21:58 +1100
committerGitHub <noreply@github.com>2017-02-01 18:21:58 +1100
commitaf7fdb32df34b352bf39f01a26653b169e0d55cf (patch)
tree4307381bb799db513dd07a0f40aec968ae99e877 /compiler/src/dotty/tools/dotc/ast
parentbb2e99cdfa9876561df912d26e9870526de3dd5d (diff)
parent678e8e47b630786df7548c1be5bee744342f826c (diff)
downloaddotty-af7fdb32df34b352bf39f01a26653b169e0d55cf.tar.gz
dotty-af7fdb32df34b352bf39f01a26653b169e0d55cf.tar.bz2
dotty-af7fdb32df34b352bf39f01a26653b169e0d55cf.zip
Merge pull request #1881 from dotty-staging/add-structural-select
Implement structural type member access
Diffstat (limited to 'compiler/src/dotty/tools/dotc/ast')
-rw-r--r--compiler/src/dotty/tools/dotc/ast/TreeInfo.scala22
1 files changed, 22 insertions, 0 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
index da83d0644..bcda4b92f 100644
--- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
+++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
@@ -629,6 +629,28 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
case nil =>
Nil
}
+
+ /** Is this a selection of a member of a structural type that is not a member
+ * of an underlying class or trait?
+ */
+ def isStructuralTermSelect(tree: Tree)(implicit ctx: Context) = tree match {
+ case tree: Select =>
+ def hasRefinement(qualtpe: Type): Boolean = qualtpe.dealias match {
+ case RefinedType(parent, rname, rinfo) =>
+ rname == tree.name || hasRefinement(parent)
+ case tp: TypeProxy =>
+ hasRefinement(tp.underlying)
+ case tp: OrType =>
+ hasRefinement(tp.tp1) || hasRefinement(tp.tp2)
+ case tp: AndType =>
+ hasRefinement(tp.tp1) && hasRefinement(tp.tp2)
+ case _ =>
+ false
+ }
+ !tree.symbol.exists && tree.isTerm && hasRefinement(tree.qualifier.tpe)
+ case _ =>
+ false
+ }
}
object TreeInfo {