diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-10-30 17:45:43 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-10-30 17:45:43 +0100 |
commit | 5540f1330862de8daeeb9f0b15b0bb0ba6f153c5 (patch) | |
tree | ef14a5ebee9020eafffeb5d906deaf7e32662106 /src/dotty/tools/dotc/typer/Typer.scala | |
parent | 9d1b4bfd96d351f3c05aeb258a708e7486f5f390 (diff) | |
download | dotty-5540f1330862de8daeeb9f0b15b0bb0ba6f153c5.tar.gz dotty-5540f1330862de8daeeb9f0b15b0bb0ba6f153c5.tar.bz2 dotty-5540f1330862de8daeeb9f0b15b0bb0ba6f153c5.zip |
merge fixes: extract typedCase to be reused in TreeChecker.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 89edd29ca..3c36a1f25 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -618,24 +618,25 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit accu(Set.empty, selType) } - def typedCase(tree: untpd.CaseDef): CaseDef = track("typedCase") { - def caseRest(pat: Tree)(implicit ctx: Context) = { - gadtSyms foreach (_.resetGADTFlexType) - pat foreachSubTree { - case b: Bind => - if (ctx.scope.lookup(b.name) == NoSymbol) ctx.enter(b.symbol) - else ctx.error(d"duplicate pattern variable: ${b.name}", b.pos) - case _ => - } - val guard1 = typedExpr(tree.guard, defn.BooleanType) - val body1 = typedExpr(tree.body, pt) - assignType(cpy.CaseDef(tree)(pat, guard1, body1), body1) + cases mapconserve (typedCase(_, pt, selType, gadtSyms)) + } + + def typedCase(tree: untpd.CaseDef, pt: Type, selType: Type, gadtSyms: Set[Symbol])(implicit ctx: Context): CaseDef = track("typedCase") { + def caseRest(pat: Tree)(implicit ctx: Context) = { + gadtSyms foreach (_.resetGADTFlexType) + pat foreachSubTree { + case b: Bind => + if (ctx.scope.lookup(b.name) == NoSymbol) ctx.enter(b.symbol) + else ctx.error(d"duplicate pattern variable: ${b.name}", b.pos) + case _ => } - val doCase: () => CaseDef = - () => caseRest(typedPattern(tree.pat, selType))(ctx.fresh.setNewScope) - (doCase /: gadtSyms)((op, tsym) => tsym.withGADTFlexType(op))() + val guard1 = typedExpr(tree.guard, defn.BooleanType) + val body1 = typedExpr(tree.body, pt) + assignType(cpy.CaseDef(tree)(pat, guard1, body1), body1) } - cases mapconserve typedCase + val doCase: () => CaseDef = + () => caseRest(typedPattern(tree.pat, selType))(ctx.fresh.setNewScope) + (doCase /: gadtSyms)((op, tsym) => tsym.withGADTFlexType(op))() } def typedReturn(tree: untpd.Return)(implicit ctx: Context): Return = track("typedReturn") { |