@@ -1176,25 +1176,25 @@ class Namer { typer: Typer =>
1176
1176
import CanForward .*
1177
1177
val sym = mbr.symbol
1178
1178
/**
1179
- * Check the export selects an abstract member of the current class (issue #22147).
1179
+ * The export selects a member of the current class (issue #22147).
1180
+ * Assumes that cls.classInfo.selfType.derivesFrom(sym.owner) is true.
1180
1181
*/
1181
- def isAbstractMember : Boolean = sym.is( Deferred ) && ( expr match
1182
- case ths : This if ths.qual.isEmpty => true // access through ' this'
1183
- case id : Ident => id.denot.info match // access through self type
1184
- case cls2 : ClassInfo => cls2.cls == cls
1185
- case _ => false
1182
+ def isCurrentMember : Boolean = expr match
1183
+ case id : ( Ident | This ) => // Access through self type or this
1184
+ /* Given the usage context below, where cls's self type is a subtype of sym.owner,
1185
+ it suffices to check if the denotation is a ClassInfo */
1186
+ id.denot.info. isInstanceOf [ ClassInfo ]
1186
1187
case _ => false
1187
- )
1188
1188
if ! sym.isAccessibleFrom(pathType) then
1189
1189
No (" is not accessible" )
1190
1190
else if sym.isConstructor || sym.is(ModuleClass ) || sym.is(Bridge ) || sym.is(ConstructorProxy ) || sym.isAllOf(JavaModule ) then
1191
1191
Skip
1192
- // if the cls is a subclass of the owner of the symbol
1192
+ // if the cls is a subclass or mixes in the owner of the symbol
1193
1193
// and either
1194
1194
// * the symbols owner is the cls itself
1195
1195
// * the symbol is not a deferred symbol
1196
- // * the symbol is an abstract member #22147
1197
- else if cls.derivesFrom(sym.owner) && (sym.owner == cls || ! sym.is(Deferred ) || isAbstractMember ) then
1196
+ // * the symbol is a member of the current class ( #22147)
1197
+ else if cls.classInfo.selfType. derivesFrom(sym.owner) && (sym.owner == cls || ! sym.is(Deferred ) || isCurrentMember ) then
1198
1198
No (i " is already a member of $cls" )
1199
1199
else if pathMethod.exists && mbr.isType then
1200
1200
No (" is a type, so it cannot be exported as extension method" )
0 commit comments