diff --git a/compiler/src/dotty/tools/dotc/core/Flags.scala b/compiler/src/dotty/tools/dotc/core/Flags.scala index 7718791b4e13..be43cbc8dfcf 100644 --- a/compiler/src/dotty/tools/dotc/core/Flags.scala +++ b/compiler/src/dotty/tools/dotc/core/Flags.scala @@ -532,8 +532,15 @@ object Flags { /** Flags that can apply to a module class */ val RetainedModuleClassFlags: FlagSet = RetainedModuleValAndClassFlags | Enum - /** Flags retained in export forwarders */ - val RetainedExportFlags = Given | Implicit | Inline | Transparent + /** Flags retained in term export forwarders */ + val RetainedExportTermFlags = Infix | Given | Implicit | Inline | Transparent | Erased | HasDefaultParams | NoDefaultParams | ExtensionMethod + + val MandatoryExportTermFlags = Exported | Method | Final + + /** Flags retained in type export forwarders */ + val RetainedExportTypeFlags = Infix + + val MandatoryExportTypeFlags = Exported | Final /** Flags that apply only to classes */ val ClassOnlyFlags = Sealed | Open | Abstract.toTypeFlags diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 819b43fcec2c..f79703ec8802 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -1199,7 +1199,7 @@ class Namer { typer: Typer => target = target.etaExpand(target.typeParams) newSymbol( cls, forwarderName, - Exported | Final, + MandatoryExportTypeFlags | (sym.flags & RetainedExportTypeFlags), TypeAlias(target), coord = span) // Note: This will always create unparameterzied aliases. So even if the original type is @@ -1245,11 +1245,8 @@ class Namer { typer: Typer => then addPathMethodParams(pathMethod.info, mbr.info.widenExpr) else mbr.info.ensureMethodic (EmptyFlags, mbrInfo) - var flagMask = RetainedExportFlags - if sym.isTerm then flagMask |= HasDefaultParams | NoDefaultParams - var mbrFlags = Exported | Method | Final | maybeStable | sym.flags & flagMask - if sym.is(ExtensionMethod) || pathMethod.exists then - mbrFlags |= ExtensionMethod + var mbrFlags = MandatoryExportTermFlags | maybeStable | (sym.flags & RetainedExportTermFlags) + if pathMethod.exists then mbrFlags |= ExtensionMethod val forwarderName = checkNoConflict(alias, isPrivate = false, span) newSymbol(cls, forwarderName, mbrFlags, mbrInfo, coord = span) diff --git a/tests/pos/i19301.scala b/tests/pos/i19301.scala new file mode 100644 index 000000000000..a4a5a858b754 --- /dev/null +++ b/tests/pos/i19301.scala @@ -0,0 +1,12 @@ +//> using options -Xfatal-warnings + +object Extensions: + infix def foo(x: String): Unit = () + extension (arg1: Int) infix def X (arg2: Int): Int = arg1 * arg2 + infix type X[A, B] + +export Extensions.* + +val x = 1 X 2 +type Foo = Int X Int +val u = Extensions foo ""