Skip to content

Commit cb97c40

Browse files
committed
Approximate annotated types in wildApprox
1 parent 701fa8a commit cb97c40

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Diff for: compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

+6
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,12 @@ object ProtoTypes {
10171017
paramInfos = tl.paramInfos.mapConserve(wildApprox(_, theMap, seen, internal1).bounds),
10181018
resType = wildApprox(tl.resType, theMap, seen, internal1)
10191019
)
1020+
case tp @ AnnotatedType(parent, _) =>
1021+
val parentApprox = wildApprox(parent, theMap, seen, internal)
1022+
if tp.isRefining then
1023+
WildcardType(TypeBounds.upper(parentApprox))
1024+
else
1025+
parentApprox
10201026
case _ =>
10211027
(if (theMap != null && seen.eq(theMap.seen)) theMap else new WildApproxMap(seen, internal))
10221028
.mapOver(tp)

Diff for: tests/pos/annot-default-arg-22839.scala

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package defaultArgBug
2+
3+
class staticAnnot(arg: Int) extends scala.annotation.StaticAnnotation
4+
class refiningAnnot(arg: Int) extends scala.annotation.RefiningAnnotation
5+
6+
def f1(a: Int, b: Int @staticAnnot(a + a) = 42): Int = b
7+
def f2(a: Int, b: Int @refiningAnnot(a + a) = 42): Int = b

0 commit comments

Comments
 (0)