Skip to content

Commit 48d50b0

Browse files
committed
Add .check file in test
1 parent 92b3d5a commit 48d50b0

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,15 +535,13 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
535535
// Make an exception for ChildAnnot, which should really have AnyKind bounds
536536
Checking.checkBounds(args, fn.tpe.widen.asInstanceOf[PolyType])
537537
if ctx.settings.Whas.inferUnion then
538-
val inferredOrTypes = args.filter(tpt =>
538+
val inferredOrTypes = args.find: tpt =>
539539
tpt.isInstanceOf[InferredTypeTree] && tpt.tpe.stripTypeVar.isInstanceOf[OrType]
540-
)
541-
inferredOrTypes.headOption.foreach(tpt =>
540+
inferredOrTypes.foreach: tpt =>
542541
report.warning(
543542
em"""|A type argument was inferred to be union type ${tpt.tpe.stripTypeVar}
544543
|This may indicate a programming error.
545544
|""", tpt.srcPos)
546-
)
547545
fn match {
548546
case sel: Select =>
549547
val args1 = transform(args)

tests/warn/infer-or-type.check

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- Warning: tests/warn/infer-or-type.scala:6:18 ------------------------------------------------------------------------
2+
6 | val _ = List(1).contains("") // warn
3+
| ^^^^^^^^^^^^^^^^
4+
| A type argument was inferred to be union type Int | String
5+
| This may indicate a programming error.
6+
-- Warning: tests/warn/infer-or-type.scala:7:10 ------------------------------------------------------------------------
7+
7 | val _ = Pair(1, "") // warn
8+
| ^^^^
9+
| A type argument was inferred to be union type Int | String
10+
| This may indicate a programming error.

0 commit comments

Comments
 (0)