@@ -34,7 +34,7 @@ import SymUtils._
3434 * This is different from the implementation of value classes in Scala 2
3535 * (see SIP-15) which uses `asInstanceOf` which does not typecheck.
3636 *
37- * Finally, if the constructor of a value class is private pr protected
37+ * Finally, if the constructor of a value class is private or protected
3838 * it is widened to public.
3939 */
4040class ExtensionMethods extends MiniPhase with DenotTransformer with FullParameterization { thisPhase =>
@@ -47,6 +47,7 @@ class ExtensionMethods extends MiniPhase with DenotTransformer with FullParamete
4747
4848 override def runsAfter = Set (
4949 ElimRepeated .name,
50+ TailRec .name, // if ran before, tailrec reports spurious errors (original method is not tailrec anymore)
5051 ProtectedAccessors .name // protected accessors cannot handle code that is moved from class to companion object
5152 )
5253
@@ -111,12 +112,7 @@ class ExtensionMethods extends MiniPhase with DenotTransformer with FullParamete
111112 moduleClassSym
112113 }
113114 case ref : SymDenotation =>
114- if (isMethodWithExtension(ref.symbol) && ref.hasAnnotation(defn.TailrecAnnot )) {
115- val ref1 = ref.copySymDenotation()
116- ref1.removeAnnotation(defn.TailrecAnnot )
117- ref1
118- }
119- else if (ref.isConstructor && isDerivedValueClass(ref.owner) && ref.is(AccessFlags )) {
115+ if (ref.isConstructor && isDerivedValueClass(ref.owner) && ref.is(AccessFlags )) {
120116 val ref1 = ref.copySymDenotation()
121117 ref1.resetFlag(AccessFlags )
122118 ref1
@@ -137,8 +133,7 @@ class ExtensionMethods extends MiniPhase with DenotTransformer with FullParamete
137133 (imeth.flags | Final ) &~ (Override | Protected | AbsOverride ),
138134 fullyParameterizedType(imeth.info, imeth.owner.asClass),
139135 privateWithin = imeth.privateWithin, coord = imeth.coord)
140- extensionMeth.addAnnotations(imeth.annotations)(ctx.withPhase(thisPhase))
141- // need to change phase to add tailrec annotation which gets removed from original method in the same phase.
136+ extensionMeth.addAnnotations(imeth.annotations)
142137 extensionMeth
143138 }
144139
0 commit comments