From 66546df50fd9afa274ed4b8aee6abd1135d7a59b Mon Sep 17 00:00:00 2001 From: odersky Date: Wed, 20 Sep 2023 22:09:19 +0200 Subject: [PATCH] Align rechecking ValDefs and DefDefs Makes things more regular and allows for a non-identity mapping between declared types and infos of vals. --- compiler/src/dotty/tools/dotc/transform/Recheck.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/transform/Recheck.scala b/compiler/src/dotty/tools/dotc/transform/Recheck.scala index e21e66550cec..cef6ddabd468 100644 --- a/compiler/src/dotty/tools/dotc/transform/Recheck.scala +++ b/compiler/src/dotty/tools/dotc/transform/Recheck.scala @@ -256,8 +256,9 @@ abstract class Recheck extends Phase, SymTransformer: bindType.symbol.info def recheckValDef(tree: ValDef, sym: Symbol)(using Context): Type = - if tree.rhs.isEmpty then sym.info - else recheck(tree.rhs, sym.info) + val resType = recheck(tree.tpt) + if tree.rhs.isEmpty then resType + else recheck(tree.rhs, resType) def recheckDefDef(tree: DefDef, sym: Symbol)(using Context): Type = inContext(linkConstructorParams(sym).withOwner(sym)):