From afad090d66ff565c856a231f6ae42dd70f75b2fc Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Thu, 6 Apr 2017 16:08:28 -0700 Subject: Use CompleterWrapper for implicitFactoryMethodCompleter mkTypeCompleter is not suitable for wrapping potentially polymorphic completers --- .../scala/tools/nsc/typechecker/MethodSynthesis.scala | 2 +- src/compiler/scala/tools/nsc/typechecker/Namers.scala | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index fd9a45166e..fea9debe7e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -223,7 +223,7 @@ trait MethodSynthesis { val methDef = factoryMeth(classDef.mods & AccessFlags | METHOD | IMPLICIT | SYNTHETIC, classDef.name.toTermName, classDef) val methSym = enterInScope(assignMemberSymbol(methDef)) context.unit.synthetics(methSym) = methDef - methSym setInfo implicitFactoryMethodCompleter(methDef, classDef.symbol, completerOf(methDef).asInstanceOf[LockingTypeCompleter]) + methSym setInfo implicitFactoryMethodCompleter(methDef, classDef.symbol) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 355d7cba30..bce55a3e31 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -869,13 +869,14 @@ trait Namers extends MethodSynthesis { import AnnotationInfo.{mkFilter => annotationFilter} - def implicitFactoryMethodCompleter(tree: DefDef, classSym: Symbol, sigCompleter: LockingTypeCompleter) = mkTypeCompleter(tree) { methSym => - sigCompleter.completeImpl(methSym) + def implicitFactoryMethodCompleter(tree: DefDef, classSym: Symbol) = new CompleterWrapper(completerOf(tree)) { + override def complete(methSym: Symbol): Unit = { + super.complete(methSym) + val annotations = classSym.initialize.annotations - val annotations = classSym.initialize.annotations - - methSym setAnnotations (annotations filter annotationFilter(MethodTargetClass, defaultRetention = false)) - classSym setAnnotations (annotations filter annotationFilter(ClassTargetClass, defaultRetention = true)) + methSym setAnnotations (annotations filter annotationFilter(MethodTargetClass, defaultRetention = false)) + classSym setAnnotations (annotations filter annotationFilter(ClassTargetClass, defaultRetention = true)) + } } // complete the type of a value definition (may have a method symbol, for those valdefs that never receive a field, -- cgit v1.2.3