@@ -1855,19 +1855,18 @@ class Namer { typer: Typer =>
1855
1855
case _ =>
1856
1856
approxTp
1857
1857
1858
- var rhsCtx = ctx.fresh.addMode(Mode .InferringReturnType )
1859
- if sym.isInlineMethod then rhsCtx = rhsCtx.addMode(Mode .InlineableBody )
1860
- if sym.is(ExtensionMethod ) then rhsCtx = rhsCtx.addMode(Mode .InExtensionMethod )
1861
- val typeParams = paramss.collect { case TypeSymbols (tparams) => tparams }.flatten
1862
- if (typeParams.nonEmpty) {
1863
- // we'll be typing an expression from a polymorphic definition's body,
1864
- // so we must allow constraining its type parameters
1865
- // compare with typedDefDef, see tests/pos/gadt-inference.scala
1866
- rhsCtx.setFreshGADTBounds
1867
- rhsCtx.gadt.addToConstraint(typeParams)
1868
- }
1869
-
1870
- def typedAheadRhs (pt : Type ) =
1858
+ def typedAheadRhs (pt : Type )(using Context ) =
1859
+ var rhsCtx = ctx.fresh.addMode(Mode .InferringReturnType )
1860
+ if sym.isInlineMethod then rhsCtx = rhsCtx.addMode(Mode .InlineableBody )
1861
+ if sym.is(ExtensionMethod ) then rhsCtx = rhsCtx.addMode(Mode .InExtensionMethod )
1862
+ val typeParams = paramss.collect { case TypeSymbols (tparams) => tparams }.flatten
1863
+ if (typeParams.nonEmpty) {
1864
+ // we'll be typing an expression from a polymorphic definition's body,
1865
+ // so we must allow constraining its type parameters
1866
+ // compare with typedDefDef, see tests/pos/gadt-inference.scala
1867
+ rhsCtx.setFreshGADTBounds
1868
+ rhsCtx.gadt.addToConstraint(typeParams)
1869
+ }
1871
1870
PrepareInlineable .dropInlineIfError(sym,
1872
1871
typedAheadExpr(mdef.rhs, pt)(using rhsCtx))
1873
1872
@@ -1877,7 +1876,8 @@ class Namer { typer: Typer =>
1877
1876
// parameters like in `def mkList[T](value: T = 1): List[T]`.
1878
1877
val defaultTp = defaultParamType
1879
1878
val pt = inherited.orElse(expectedDefaultArgType).orElse(fallbackProto).widenExpr
1880
- val tp = typedAheadRhs(pt).tpe
1879
+ val preciseMode = if (defaultTp.isPrecise) Mode .Precise else Mode .None
1880
+ val tp = withMode(preciseMode){ typedAheadRhs(pt) }.tpe
1881
1881
if (defaultTp eq pt) && (tp frozen_<:< defaultTp) then
1882
1882
// When possible, widen to the default getter parameter type to permit a
1883
1883
// larger choice of overrides (see `default-getter.scala`).
0 commit comments