aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2014-09-09 16:16:16 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-09-17 18:07:17 +0200
commit8f6ce34a846fedad7c939403918a3d7d7da9d72b (patch)
treef02387158bf7d556221e6078aa6e81e0a2cc57ad /src
parent899554fc34038be1ff2fe6fbd2bc38f1f39dce5b (diff)
downloaddotty-8f6ce34a846fedad7c939403918a3d7d7da9d72b.tar.gz
dotty-8f6ce34a846fedad7c939403918a3d7d7da9d72b.tar.bz2
dotty-8f6ce34a846fedad7c939403918a3d7d7da9d72b.zip
Remaining definitions for patmat.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/transform/PatternMatcher.scala13
-rw-r--r--src/dotty/tools/dotc/transform/TypeUtils.scala6
2 files changed, 16 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/transform/PatternMatcher.scala b/src/dotty/tools/dotc/transform/PatternMatcher.scala
index 1b3d19239..a2d6e2110 100644
--- a/src/dotty/tools/dotc/transform/PatternMatcher.scala
+++ b/src/dotty/tools/dotc/transform/PatternMatcher.scala
@@ -1860,9 +1860,20 @@ class PatternMatcher extends MiniPhaseTransform {
aligned
}
+ object Applied {
+ // Duplicated with `spliceApply`
+ def unapply(tree: Tree): Option[Tree] = tree match {
+ // SI-7868 Admit Select() to account for numeric widening, e.g. <unappplySelector>.toInt
+ case Apply(fun, (Ident(nme.SELECTOR_DUMMY)| Select(Ident(nme.SELECTOR_DUMMY), _)) :: Nil)
+ => Some(fun)
+ case Apply(fun, _) => unapply(fun)
+ case _ => None
+ }
+ }
+
def apply(tree:Tree, sel: Tree, args: List[Tree], resultType: Type): Aligned = {
val fn = sel match {
- case Unapplied(fn) => fn
+ case Applied(fn) => fn
case _ => sel
}
val patterns = newPatterns(args)
diff --git a/src/dotty/tools/dotc/transform/TypeUtils.scala b/src/dotty/tools/dotc/transform/TypeUtils.scala
index 109a04af3..ceb4048a7 100644
--- a/src/dotty/tools/dotc/transform/TypeUtils.scala
+++ b/src/dotty/tools/dotc/transform/TypeUtils.scala
@@ -13,17 +13,19 @@ import language.implicitConversions
object TypeUtils {
implicit def decorateTypeUtils(tpe: Type): TypeUtils = new TypeUtils(tpe)
-
}
/** A decorator that provides methods on types
* that are needed in the transformer pipeline.
*/
class TypeUtils(val self: Type) extends AnyVal {
+ import TypeUtils._
def isErasedValueType(implicit ctx: Context): Boolean =
self.isInstanceOf[ErasedValueType]
def isPrimitiveValueType(implicit ctx: Context): Boolean =
self.classSymbol.isPrimitiveValueClass
-}
+
+ def caseAccessors(implicit ctx:Context) = self.decls.filter(x => x.is(Flags.CaseAccessor) && x.is(Flags.Method)).toList
+} \ No newline at end of file