Skip to content

Revert "Do not lift annotation arguments" from 3.3 LTS #23062

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ trait TreeInfo[T <: Untyped] { self: Trees.Instance[T] =>
def allTermArguments(tree: Tree): List[Tree] = unsplice(tree) match {
case Apply(fn, args) => allTermArguments(fn) ::: args
case TypeApply(fn, args) => allTermArguments(fn)
case Block(Nil, expr) => allTermArguments(expr)
case Block(_, expr) => allTermArguments(expr)
case _ => Nil
}

/** All type and term arguments of an application in a single flattened list */
def allArguments(tree: Tree): List[Tree] = unsplice(tree) match {
case Apply(fn, args) => allArguments(fn) ::: args
case TypeApply(fn, args) => allArguments(fn) ::: args
case Block(Nil, expr) => allArguments(expr)
case Block(_, expr) => allArguments(expr)
case _ => Nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
def recur(t: untpd.Tree): Text = t match
case Apply(fn, Nil) => recur(fn)
case Apply(fn, args) =>
val explicitArgs = args.filterNot(untpd.stripNamedArg(_).symbol.name.is(DefaultGetterName))
val explicitArgs = args.filterNot(_.symbol.name.is(DefaultGetterName))
recur(fn) ~ "(" ~ toTextGlobal(explicitArgs, ", ") ~ ")"
case TypeApply(fn, args) => recur(fn) ~ "[" ~ toTextGlobal(args, ", ") ~ "]"
case Select(qual, nme.CONSTRUCTOR) => recur(qual)
Expand Down
9 changes: 1 addition & 8 deletions compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ trait Applications extends Compatibility {
case tp => args.size
}

!isAnnotConstr(methRef.symbol) &&
!isJavaAnnotConstr(methRef.symbol) &&
args.size < requiredArgNum(funType)
}

Expand Down Expand Up @@ -611,11 +611,6 @@ trait Applications extends Compatibility {
def isJavaAnnotConstr(sym: Symbol): Boolean =
sym.is(JavaDefined) && sym.isConstructor && sym.owner.is(JavaAnnotation)


/** Is `sym` a constructor of an annotation? */
def isAnnotConstr(sym: Symbol): Boolean =
sym.isConstructor && sym.owner.isAnnotation

/** Match re-ordered arguments against formal parameters
* @param n The position of the first parameter in formals in `methType`.
*/
Expand Down Expand Up @@ -905,8 +900,6 @@ trait Applications extends Compatibility {
val app1 =
if !success then app0.withType(UnspecifiedErrorType)
else {
if isAnnotConstr(methRef.symbol) && !isJavaAnnotConstr(methRef.symbol) then
typedArgs
if !sameSeq(args, orderedArgs)
&& !isJavaAnnotConstr(methRef.symbol)
&& !typedArgs.forall(isSafeArg)
Expand Down
25 changes: 0 additions & 25 deletions tests/printing/dependent-annot-default-args.check

This file was deleted.

6 changes: 0 additions & 6 deletions tests/printing/dependent-annot-default-args.scala

This file was deleted.

Loading