diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-12-18 10:07:23 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-12-18 10:07:23 -0800 |
commit | ecc63690f11c0c72bff62c79277761b0a04f259c (patch) | |
tree | 72abc8e4d759eb812dea0bbd8068cfea33e042fe /src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala | |
parent | 640c95500e73f811fb86c4267afc504ff3be1e7b (diff) | |
parent | 5b8327b807c40cab867065cf695191a36c9210ee (diff) | |
download | scala-ecc63690f11c0c72bff62c79277761b0a04f259c.tar.gz scala-ecc63690f11c0c72bff62c79277761b0a04f259c.tar.bz2 scala-ecc63690f11c0c72bff62c79277761b0a04f259c.zip |
Merge pull request #4122 from retronym/ticket/7459-2
SI-7459 Handle pattern binders used as prefixes in TypeTrees.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala index 25f7224667..0678ec52e7 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala @@ -248,7 +248,10 @@ trait MatchTranslation { if (caseDefs forall treeInfo.isCatchCase) caseDefs else { val swatches = { // switch-catches - val bindersAndCases = caseDefs map { caseDef => + // SI-7459 must duplicate here as we haven't commited to switch emission, and just figuring out + // if we can ends up mutating `caseDefs` down in the use of `substituteSymbols` in + // `TypedSubstitution#Substitution`. That is called indirectly by `emitTypeSwitch`. + val bindersAndCases = caseDefs.map(_.duplicate) map { caseDef => // generate a fresh symbol for each case, hoping we'll end up emitting a type-switch (we don't have a global scrut there) // if we fail to emit a fine-grained switch, have to do translateCase again with a single scrutSym (TODO: uniformize substitution on treemakers so we can avoid this) val caseScrutSym = freshSym(pos, pureType(ThrowableTpe)) @@ -518,7 +521,7 @@ trait MatchTranslation { // reference the (i-1)th case accessor if it exists, otherwise the (i-1)th tuple component override protected def tupleSel(binder: Symbol)(i: Int): Tree = { val accessors = binder.caseFieldAccessors - if (accessors isDefinedAt (i-1)) REF(binder) DOT accessors(i-1) + if (accessors isDefinedAt (i-1)) gen.mkAttributedStableRef(binder) DOT accessors(i-1) else codegen.tupleSel(binder)(i) // this won't type check for case classes, as they do not inherit ProductN } } |