Skip to content

Commit 1ed5d3c

Browse files
committed
Document dropping @Repeated annotation
1 parent ff2c602 commit 1ed5d3c

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ trait ConstraintHandling[AbstractContext] {
277277
* of `scala.Singleton`, widen `tp`.
278278
* 2. If `tp` is a union type, yet upper bound is not a union type,
279279
* approximate the union type from above by an intersection of all common base types.
280+
*
281+
* At this point we also drop the @Repeated annotation to avoid inferring type arguments with it,
282+
* as those could leak the annotation to users (see run/inferred-repeated-result).
280283
*/
281284
def widenInferred(tp: Type, bound: Type)(implicit actx: AbstractContext): Type = {
282285
def isMultiSingleton(tp: Type): Boolean = tp.stripAnnots match {

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,8 @@ class Namer { typer: Typer =>
13201320
// Widen rhs type and eliminate `|' but keep ConstantTypes if
13211321
// definition is inline (i.e. final in Scala2) and keep module singleton types
13221322
// instead of widening to the underlying module class types.
1323+
// We also drop the @Repeated annotation here to avoid leaking it in method result types
1324+
// (see run/inferred-repeated-result).
13231325
def widenRhs(tp: Type): Type = {
13241326
val tp1 = tp.widenTermRefExpr match {
13251327
case ctp: ConstantType if isInlineVal => ctp

0 commit comments

Comments
 (0)