File tree 3 files changed +9
-2
lines changed
src/dotty/tools/dotc/typer
3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -491,7 +491,7 @@ trait Implicits { self: Typer =>
491
491
pt)
492
492
val generated1 = adapt(generated, pt)
493
493
lazy val shadowing =
494
- typed(untpd.Ident (ref.name) withPos pos.toSynthetic, funProto)(nestedContext.setNewTyperState)
494
+ typed(untpd.Ident (ref.name) withPos pos.toSynthetic, funProto)(nestedContext.setNewTyperState.addMode( Mode . ImplicitShadowing ) )
495
495
def refMatches (shadowing : Tree ): Boolean =
496
496
ref.symbol == closureBody(shadowing).symbol || {
497
497
shadowing match {
@@ -501,7 +501,8 @@ trait Implicits { self: Typer =>
501
501
}
502
502
if (ctx.typerState.reporter.hasErrors)
503
503
nonMatchingImplicit(ref)
504
- else if (contextual && ! shadowing.tpe.isError && ! refMatches(shadowing)) {
504
+ else if (contextual && ! ctx.mode.is(Mode .ImplicitShadowing ) &&
505
+ ! shadowing.tpe.isError && ! refMatches(shadowing)) {
505
506
implicits.println(i " SHADOWING $ref in ${ref.termSymbol.owner} is shadowed by $shadowing in ${shadowing.symbol.owner}" )
506
507
shadowedImplicit(ref, methPart(shadowing).tpe)
507
508
}
Original file line number Diff line number Diff line change @@ -68,5 +68,10 @@ object Mode {
68
68
*/
69
69
val Printing = newMode(10 , " Printing" )
70
70
71
+ /** We are currently typechecking an ident to determine whether some implicit
72
+ * is shadowed - don't do any other shadowing tests.
73
+ */
74
+ val ImplicitShadowing = newMode(11 , " ImplicitShadowing" )
75
+
71
76
val PatternOrType = Pattern | Type
72
77
}
Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ class tests extends CompilerTest {
137
137
@ Test def neg_escapingRefs = compileFile(negDir, " escapingRefs" , xerrors = 2 )
138
138
@ Test def neg_instantiateAbstract = compileFile(negDir, " instantiateAbstract" , xerrors = 8 )
139
139
@ Test def neg_selfInheritance = compileFile(negDir, " selfInheritance" , xerrors = 5 )
140
+ @ Test def neg_shadowedImplicits = compileFile(negDir, " arrayclone-new" , xerrors = 2 )
140
141
141
142
@ Test def run_all = runFiles(runDir)
142
143
You can’t perform that action at this time.
0 commit comments