@@ -62,8 +62,21 @@ object Typer {
62
62
if (! tree.isEmpty && ! tree.isInstanceOf [untpd.TypedSplice ] && ctx.typerState.isGlobalCommittable)
63
63
assert(tree.pos.exists, s " position not set for $tree # ${tree.uniqueId}" )
64
64
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
+ */
65
69
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
+ */
66
74
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 ]
67
80
}
68
81
69
82
class 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
1862
1875
*
1863
1876
* 0th strategy: If `tree` overrides a nullary method, mark the prototype
1864
1877
* so that the argument is dropped and return `tree` itself.
1878
+ * (but do this at most once per tree).
1865
1879
*
1866
1880
* After that, two strategies are tried, and the first that is successful is picked.
1867
1881
* 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
1899
1913
1900
1914
pt match {
1901
1915
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 , ())
1903
1919
pt.markAsDropped()
1904
1920
tree
1905
1921
case _ =>
0 commit comments