PatternMatcher

dotty.tools.dotc.transform.PatternMatcher$
See thePatternMatcher companion class

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

class Translator(resultType: Type, thisPhase: MiniPhase)(using x$3: Context)

The pattern matching translator. Its general structure is a pipeline:

The pattern matching translator. Its general structure is a pipeline:

Match tree ---matchPlan---> Plan ---optimize---> Plan ---emit---> Tree

The pipeline consists of three steps:

  • build a plan, using methods matchPlan, caseDefPlan, patternPlan.
  • optimize the plan, using methods listed in optimization,
  • emit the translated tree, using methods emit, collectSwitchCases, emitSwitchCases, and emitCondition.

A plan represents the underlying decision graph. It consists of tests, let bindings, labeled blocks, return from said labeled blocks and code blocks. It's represented by its own data type. Plans are optimized by merging common tests and eliminating dead code.

Attributes

Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

Was symbol generated by pattern matcher?

Was symbol generated by pattern matcher?

Attributes

Concrete fields

inline val MinSwitchCases: 4

Minimal number of cases to emit a switch

Minimal number of cases to emit a switch

Attributes

val name: String
inline val selfCheck: false