@@ -62,8 +62,21 @@ object Typer {
6262 if (! tree.isEmpty && ! tree.isInstanceOf [untpd.TypedSplice ] && ctx.typerState.isGlobalCommittable)
6363 assert(tree.pos.exists, s " position not set for $tree # ${tree.uniqueId}" )
6464
65+ /** A context property that indicates the owner of any expressions to be typed in the context
66+ * if that owner is different from the context's owner. Typically, a context with a class
67+ * as owner would have a local dummy as ExprOwner value.
68+ */
6569 private val ExprOwner = new Property .Key [Symbol ]
70+
71+ /** An attachment on a Select node with an `apply` field indicating that the `apply`
72+ * was inserted by the Typer.
73+ */
6674 private val InsertedApply = new Property .Key [Unit ]
75+
76+ /** An attachment on a tree `t` occurring as part of a `t()` where
77+ * the `()` was dropped by the Typer.
78+ */
79+ private val DroppedEmptyArgs = new Property .Key [Unit ]
6780}
6881
6982class Typer extends Namer with TypeAssigner with Applications with Implicits with Dynamic with Checking with Docstrings {
@@ -1862,6 +1875,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
18621875 *
18631876 * 0th strategy: If `tree` overrides a nullary method, mark the prototype
18641877 * so that the argument is dropped and return `tree` itself.
1878+ * (but do this at most once per tree).
18651879 *
18661880 * After that, two strategies are tried, and the first that is successful is picked.
18671881 * If neither of the strategies are successful, continues with`fallBack`.
@@ -1899,7 +1913,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
18991913
19001914 pt match {
19011915 case pt @ FunProto (Nil , _, _)
1902- if tree.symbol.allOverriddenSymbols.exists(_.info.isNullaryMethod) =>
1916+ if tree.symbol.allOverriddenSymbols.exists(_.info.isNullaryMethod) &&
1917+ tree.getAttachment(DroppedEmptyArgs ).isEmpty =>
1918+ tree.putAttachment(DroppedEmptyArgs , ())
19031919 pt.markAsDropped()
19041920 tree
19051921 case _ =>
0 commit comments