From e3a49c2148693b11e81e6fabd89ae34af520980a Mon Sep 17 00:00:00 2001 From: odersky Date: Sat, 2 Jul 2022 11:30:11 +0200 Subject: [PATCH] Only check explicitly given type arguments --- compiler/src/dotty/tools/dotc/transform/PostTyper.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala index 10dcad13d49f..83bc70f284fb 100644 --- a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala @@ -345,7 +345,11 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase val tree1 @ TypeApply(fn, args) = normalizeTypeArgs(tree) for arg <- args do checkInferredWellFormed(arg) - Checking.checkGoodBounds(arg.tpe, arg.srcPos) + if !arg.span.isZeroExtent then + // only check explicit type arguments. We rely on inferred type arguments + // to either have good bounds (if they come from a constraint), or be derived + // from values that recursively need to have good bounds. + Checking.checkGoodBounds(arg.tpe, arg.srcPos) if (fn.symbol != defn.ChildAnnot.primaryConstructor) // Make an exception for ChildAnnot, which should really have AnyKind bounds Checking.checkBounds(args, fn.tpe.widen.asInstanceOf[PolyType])