Skip to content

Commit 07e7f93

Browse files
committed
Generate implied @infix annotation as untyped tree
Generating it as a typed tree will lead to a duplicate class `annotation.infix` on bootstrap. Also, update a check file to report the inserted @infix annotation.
1 parent d068675 commit 07e7f93

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
445445

446446
def rootDot(name: Name)(implicit src: SourceFile): Select = Select(Ident(nme.ROOTPKG), name)
447447
def scalaDot(name: Name)(implicit src: SourceFile): Select = Select(rootDot(nme.scala_), name)
448+
def scalaAnnotationDot(name: Name)(using SourceFile): Select = Select(scalaDot(nme.annotation), name)
448449
def scalaUnit(implicit src: SourceFile): Select = scalaDot(tpnme.Unit)
449450
def scalaAny(implicit src: SourceFile): Select = scalaDot(tpnme.Any)
450451
def javaDotLangDot(name: Name)(implicit src: SourceFile): Select = Select(Select(Ident(nme.java), nme.lang), name)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ object StdNames {
486486
val implicitly: N = "implicitly"
487487
val in: N = "in"
488488
val inline: N = "inline"
489+
val infix: N = "infix"
489490
val info: N = "info"
490491
val inlinedEquals: N = "inlinedEquals"
491492
val internal: N = "internal"

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3217,7 +3217,7 @@ object Parsers {
32173217
val ident = termIdent()
32183218
val name = ident.name.asTermName
32193219
if isInfix && !name.isOperatorName then
3220-
val infixAnnot = Apply(wrapNew(ref(defn.InfixAnnot.typeRef)), Nil)
3220+
val infixAnnot = Apply(wrapNew(scalaAnnotationDot(tpnme.infix)), Nil)
32213221
.withSpan(Span(start, start))
32223222
mods1 = mods1.withAddedAnnotation(infixAnnot)
32233223
val tparams =

tests/printing/i620.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ package O {
1111
protected[A] def f: Int = 0
1212
def g: Int = 0
1313
def g1(t: Int): Int = 0
14-
def (c: D.this.C) g1: Int = 0
14+
@_root_.scala.annotation.infix() def (c: D.this.C) g1: Int = 0
1515
}
1616
private[D] class E() extends Object() {}
1717
private[this] class F() extends Object() {}

0 commit comments

Comments
 (0)