@@ -11,7 +11,7 @@ import dotty.tools.dotc.ast.{Trees, tpd}
1111import scala .collection .{ mutable , immutable }
1212import mutable .ListBuffer
1313import core ._
14- import Phases .Phase
14+ import dotty . tools . dotc . core . Phases .{ NeedsCompanions , Phase }
1515import Types ._ , Contexts ._ , Constants ._ , Names ._ , NameOps ._ , Flags ._ , DenotTransformers ._
1616import SymDenotations ._ , Symbols ._ , StdNames ._ , Annotations ._ , Trees ._ , Scopes ._ , Denotations ._
1717import TypeErasure .{ valueErasure , ErasedValueType }
@@ -33,7 +33,7 @@ import SymUtils._
3333 * This is different from the implementation of value classes in Scala 2
3434 * (see SIP-15) which uses `asInstanceOf` which does not typecheck.
3535 */
36- class ExtensionMethods extends MiniPhaseTransform with DenotTransformer with FullParameterization { thisTransformer =>
36+ class ExtensionMethods extends MiniPhaseTransform with DenotTransformer with FullParameterization with NeedsCompanions { thisTransformer =>
3737
3838 import tpd ._
3939 import ExtensionMethods ._
@@ -45,6 +45,10 @@ class ExtensionMethods extends MiniPhaseTransform with DenotTransformer with Ful
4545
4646 override def runsAfterGroupsOf = Set (classOf [FirstTransform ]) // need companion objects to exist
4747
48+ def isCompanionNeeded (cls : ClassSymbol )(implicit ctx : Context ): Boolean = {
49+ isDerivedValueClass(cls)
50+ }
51+
4852 override def transform (ref : SingleDenotation )(implicit ctx : Context ): SingleDenotation = ref match {
4953 case moduleClassSym : ClassDenotation if moduleClassSym is ModuleClass =>
5054 moduleClassSym.linkedClass match {
0 commit comments