@@ -245,9 +245,9 @@ object ExplicitOuter {
245
245
private def hasOuter (cls : ClassSymbol )(using Context ): Boolean =
246
246
needsOuterIfReferenced(cls) && outerAccessor(cls).exists
247
247
248
- /** Class constructor takes an outer argument. Can be called only after phase ExplicitOuter. */
249
- def hasOuterParam (cls : ClassSymbol )(using Context ): Boolean =
250
- ! cls.is(Trait ) && needsOuterIfReferenced(cls) && outerAccessor(cls).exists
248
+ /** Class constructor needs an outer argument. Can be called only after phase ExplicitOuter. */
249
+ def needsOuterParam (cls : ClassSymbol )(using Context ): Boolean =
250
+ ! cls.is(Trait ) && needsOuterIfReferenced(cls) && (cls.is( JavaDefined ) || outerAccessor(cls).exists)
251
251
252
252
/** Tree references an outer class of `cls` which is not a static owner.
253
253
*/
@@ -357,7 +357,7 @@ object ExplicitOuter {
357
357
358
358
/** If `cls` has an outer parameter add one to the method type `tp`. */
359
359
def addParam (cls : ClassSymbol , tp : Type ): Type =
360
- if (hasOuterParam (cls)) {
360
+ if (needsOuterParam (cls)) {
361
361
val mt @ MethodTpe (pnames, ptypes, restpe) = tp
362
362
mt.derivedLambdaType(
363
363
nme.OUTER :: pnames, outerClass(cls).typeRef :: ptypes, restpe)
@@ -378,7 +378,7 @@ object ExplicitOuter {
378
378
case TypeApply (Select (r, nme.asInstanceOf_), args) =>
379
379
outerArg(r) // cast was inserted, skip
380
380
}
381
- if (hasOuterParam (cls))
381
+ if (needsOuterParam (cls))
382
382
methPart(fun) match {
383
383
case Select (receiver, _) => outerArg(receiver).withSpan(fun.span) :: Nil
384
384
}
@@ -390,7 +390,7 @@ object ExplicitOuter {
390
390
* argument, the singleton list with the argument, otherwise Nil.
391
391
*/
392
392
def argsForNew (cls : ClassSymbol , tpe : Type ): List [Tree ] =
393
- if (hasOuterParam (cls)) singleton(fixThis(outerPrefix(tpe))) :: Nil
393
+ if (needsOuterParam (cls)) singleton(fixThis(outerPrefix(tpe))) :: Nil
394
394
else Nil
395
395
396
396
/** A path of outer accessors starting from node `start`. `start` defaults to the
0 commit comments