diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 9b286163c468..39b34523042c 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -1394,14 +1394,10 @@ class Namer { typer: Typer => } def typedAheadType(tree: Tree, pt: Type = WildcardType)(using Context): tpd.Tree = - inMode(ctx.mode &~ Mode.PatternOrTypeBits | Mode.Type) { - typedAhead(tree, typer.typed(_, pt)) - } + typedAhead(tree, typer.typedType(_, pt)) def typedAheadExpr(tree: Tree, pt: Type = WildcardType)(using Context): tpd.Tree = - withoutMode(Mode.PatternOrTypeBits) { - typedAhead(tree, typer.typed(_, pt)) - } + typedAhead(tree, typer.typedExpr(_, pt)) def typedAheadAnnotation(tree: Tree)(using Context): tpd.Tree = typedAheadExpr(tree, defn.AnnotationClass.typeRef) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 96e3d13a9cb2..f76d47f717cd 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -2959,7 +2959,7 @@ class Typer extends Namer def typedExpr(tree: untpd.Tree, pt: Type = WildcardType)(using Context): Tree = withoutMode(Mode.PatternOrTypeBits)(typed(tree, pt)) def typedType(tree: untpd.Tree, pt: Type = WildcardType)(using Context): Tree = // todo: retract mode between Type and Pattern? - withMode(Mode.Type)(typed(tree, pt)) + withMode(Mode.Type) { typed(tree, pt) } def typedPattern(tree: untpd.Tree, selType: Type = WildcardType)(using Context): Tree = withMode(Mode.Pattern)(typed(tree, selType))