@@ -16,6 +16,7 @@ import ContextFunctionResults.annotateContextResults
1616import config .Printers .typr
1717import util .SrcPos
1818import reporting ._
19+ import NameKinds .WildcardParamName
1920
2021object PostTyper {
2122 val name : String = " posttyper"
@@ -345,12 +346,6 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
345346 val tree1 @ TypeApply (fn, args) = normalizeTypeArgs(tree)
346347 for arg <- args do
347348 checkInferredWellFormed(arg)
348- val isInferred = arg.isInstanceOf [InferredTypeTree ] || arg.span.isSynthetic
349- if ! isInferred then
350- // only check explicit type arguments. We rely on inferred type arguments
351- // to either have good bounds (if they come from a constraint), or be derived
352- // from values that recursively need to have good bounds.
353- Checking .checkGoodBounds(arg.tpe, arg.srcPos)
354349 if (fn.symbol != defn.ChildAnnot .primaryConstructor)
355350 // Make an exception for ChildAnnot, which should really have AnyKind bounds
356351 Checking .checkBounds(args, fn.tpe.widen.asInstanceOf [PolyType ])
@@ -403,13 +398,20 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
403398 val reference = ctx.settings.sourceroot.value
404399 val relativePath = util.SourceFile .relativePath(ctx.compilationUnit.source, reference)
405400 sym.addAnnotation(Annotation .makeSourceFile(relativePath))
406- else (tree.rhs, sym.info) match
407- case (rhs : LambdaTypeTree , bounds : TypeBounds ) =>
408- VarianceChecker .checkLambda(rhs, bounds)
409- if sym.isOpaqueAlias then
410- VarianceChecker .checkLambda(rhs, TypeBounds .upper(sym.opaqueAlias))
411- case _ =>
401+ else
402+ if ! sym.is(Param ) && ! sym.owner.isOneOf(AbstractOrTrait ) then
403+ Checking .checkGoodBounds(tree.symbol)
404+ (tree.rhs, sym.info) match
405+ case (rhs : LambdaTypeTree , bounds : TypeBounds ) =>
406+ VarianceChecker .checkLambda(rhs, bounds)
407+ if sym.isOpaqueAlias then
408+ VarianceChecker .checkLambda(rhs, TypeBounds .upper(sym.opaqueAlias))
409+ case _ =>
412410 processMemberDef(super .transform(tree))
411+ case tree : Bind =>
412+ if tree.symbol.isType && ! tree.symbol.name.is(WildcardParamName ) then
413+ Checking .checkGoodBounds(tree.symbol)
414+ super .transform(tree)
413415 case tree : New if isCheckable(tree) =>
414416 Checking .checkInstantiable(tree.tpe, tree.srcPos)
415417 super .transform(tree)
0 commit comments