Skip to content

Commit 3f16d46

Browse files
committed
WIP
1 parent e0256bd commit 3f16d46

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,16 @@ class CheckCaptures extends Recheck, SymTransformer:
962962
openClosures = openClosures.tail
963963
end recheckClosureBlock
964964

965+
override def recheckReturn(tree: Return)(using Context): Type =
966+
super.recheckReturn(tree)
967+
val sym = tree.symbol
968+
if sym.exists then
969+
// check that the return type conforms to the expected type
970+
val resType = tree.expr.nuType
971+
val expectedType = sym.info
972+
checkConformsExpr(resType, expectedType, tree)
973+
defn.NothingType
974+
965975
/** Elements of a SeqLiteral instantiate a Seq or Array parameter, so they
966976
* should be boxed.
967977
*/

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,13 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
685685
case tree: Bind =>
686686
val sym = tree.symbol
687687
updateInfo(sym, transformInferredType(sym.info), sym.owner)
688+
689+
case tree: Labeled =>
690+
val sym = tree.bind.symbol
691+
if sym.exists then
692+
println(i"update info of $sym in ${ctx.owner} from ${sym.info} to ${transformInferredType(sym.info)}, tree = $tree")
693+
updateInfo(sym, transformInferredType(sym.info), sym.owner)
694+
688695
case tree: TypeDef =>
689696
tree.symbol match
690697
case cls: ClassSymbol =>

tests/neg-custom-args/captures/match.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ def test =
1919

2020
val x4: AnyRef = a match
2121
case b: B => b.x // error
22+
23+
val x5: AnyRef^{x} = a match
24+
case b: B =>
25+
val bx: AnyRef^{b.x} = b.x
26+
bx

0 commit comments

Comments
 (0)