diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index 0cc4aaabfc93..278352ed62f4 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -1017,6 +1017,12 @@ object ProtoTypes { paramInfos = tl.paramInfos.mapConserve(wildApprox(_, theMap, seen, internal1).bounds), resType = wildApprox(tl.resType, theMap, seen, internal1) ) + case tp @ AnnotatedType(parent, _) => + val parentApprox = wildApprox(parent, theMap, seen, internal) + if tp.isRefining then + WildcardType(TypeBounds.upper(parentApprox)) + else + parentApprox case _ => (if (theMap != null && seen.eq(theMap.seen)) theMap else new WildApproxMap(seen, internal)) .mapOver(tp) diff --git a/tests/pos/annot-default-arg-22839.scala b/tests/pos/annot-default-arg-22839.scala new file mode 100644 index 000000000000..7a983f4d3351 --- /dev/null +++ b/tests/pos/annot-default-arg-22839.scala @@ -0,0 +1,7 @@ +package defaultArgBug + +class staticAnnot(arg: Int) extends scala.annotation.StaticAnnotation +class refiningAnnot(arg: Int) extends scala.annotation.RefiningAnnotation + +def f1(a: Int, b: Int @staticAnnot(a + a) = 42): Int = b +def f2(a: Int, b: Int @refiningAnnot(a + a) = 42): Int = b