@@ -133,10 +133,7 @@ class TreeChecker extends Phase with SymTransformer {
133
133
catch {
134
134
case NonFatal (ex) => // TODO CHECK. Check that we are bootstrapped
135
135
implicit val ctx : Context = checkingCtx
136
- ctx.echo(i " *** error while checking ${ctx.compilationUnit} after phase ${checkingCtx.phase.prev} *** " )
137
- ctx.echo(ex.toString)
138
- ctx.echo(ex.getStackTrace.take(30 ).deep.mkString(" \n " ))
139
- ctx.echo(" <<<" )
136
+ println(i " *** error while checking ${ctx.compilationUnit} after phase ${checkingCtx.phase.prev} *** " )
140
137
throw ex
141
138
}
142
139
}
@@ -332,8 +329,30 @@ class TreeChecker extends Phase with SymTransformer {
332
329
checkNotRepeated(super .typedIdent(tree, pt))
333
330
}
334
331
332
+ /** Makes sure the symbol in the tree can be approximately reconstructed by
333
+ * calling `member` on the qualifier type.
334
+ * Approximately means: The two symbols might be different but one still overrides the other.
335
+ */
335
336
override def typedSelect (tree : untpd.Select , pt : Type )(implicit ctx : Context ): Tree = {
336
337
assert(tree.isTerm || ! ctx.isAfterTyper, tree.show + " at " + ctx.phase)
338
+ val tpe = tree.typeOpt
339
+ val sym = tree.symbol
340
+ if (! tpe.isInstanceOf [WithFixedSym ] && sym.exists && ! sym.is(Private )) {
341
+ val qualTpe = tree.qualifier.typeOpt
342
+ val member =
343
+ if (sym.is(Private )) qualTpe.member(tree.name)
344
+ else qualTpe.nonPrivateMember(tree.name)
345
+ val memberSyms = member.alternatives.map(_.symbol)
346
+ assert(memberSyms.exists(mbr =>
347
+ sym == mbr ||
348
+ sym.overriddenSymbol(mbr.owner.asClass) == mbr ||
349
+ mbr.overriddenSymbol(sym.owner.asClass) == sym),
350
+ ex """ symbols differ for $tree
351
+ |was : $sym
352
+ |alternatives by type: $memberSyms%, % of types ${memberSyms.map(_.info)}%, %
353
+ |qualifier type : ${tree.qualifier.typeOpt}
354
+ |tree type : ${tree.typeOpt} of class ${tree.typeOpt.getClass}""" )
355
+ }
337
356
checkNotRepeated(super .typedSelect(tree, pt))
338
357
}
339
358
0 commit comments