Skip to content

Commit c1b0ab6

Browse files
committed
Fixes for type argument handling.
(1) Type arguments now get a coordinate. (2) They are labeled Override (2) avoids having to special case TypeArgs in OverridingPairs.
1 parent 387bdf9 commit c1b0ab6

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,13 @@ object SymDenotations {
805805
* either as overrider or overridee.
806806
*/
807807
final def canMatchInheritedSymbols(implicit ctx: Context): Boolean =
808-
maybeOwner.isClass && !isConstructor && !is(Private)
808+
maybeOwner.isClass && memberCanMatchInheritedSymbols
809+
810+
/** If false, this class member cannot possibly participate in an override,
811+
* either as overrider or overridee.
812+
*/
813+
final def memberCanMatchInheritedSymbols(implicit ctx: Context): Boolean =
814+
!isConstructor && !is(Private)
809815

810816
/** The symbol, in class `inClass`, that is overridden by this denotation. */
811817
final def overriddenSymbol(inClass: ClassSymbol)(implicit ctx: Context): Symbol =

src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@ trait TypeOps { this: Context =>
197197
}
198198
}
199199

200-
201-
202200
private def enterArgBinding(formal: Symbol, info: Type, cls: ClassSymbol, decls: Scope) = {
203201
val lazyInfo = new LazyType { // needed so we do not force `formal`.
204202
def complete(denot: SymDenotation)(implicit ctx: Context): Unit = {
@@ -207,7 +205,11 @@ trait TypeOps { this: Context =>
207205
}
208206
}
209207
val typeArgFlag = if (formal is Local) TypeArgument else EmptyFlags
210-
val sym = ctx.newSymbol(cls, formal.name, formal.flagsUNSAFE & RetainedTypeArgFlags | typeArgFlag, lazyInfo)
208+
val sym = ctx.newSymbol(
209+
cls, formal.name,
210+
formal.flagsUNSAFE & RetainedTypeArgFlags | typeArgFlag | Override,
211+
lazyInfo,
212+
coord = cls.coord)
211213
cls.enter(sym, decls)
212214
}
213215

src/dotty/tools/dotc/transform/OverridingPairs.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ object OverridingPairs {
3030
/** Symbols to exclude: Here these are constructors and private locals.
3131
* But it may be refined in subclasses.
3232
*/
33-
protected def exclude(sym: Symbol): Boolean =
34-
sym.isConstructor ||
35-
sym.is(Private) ||
36-
sym.is(ExcludedType)
33+
protected def exclude(sym: Symbol): Boolean = !sym.memberCanMatchInheritedSymbols
3734

3835
/** The parents of base (may also be refined).
3936
*/

0 commit comments

Comments
 (0)