@@ -382,7 +382,7 @@ object SymDenotations {
382
382
383
383
final def normalizeOpaque ()(implicit ctx : Context ) = {
384
384
if (is(Opaque )) {
385
- addAnnotation(Annotation .OpaqueAlias (info))
385
+ addAnnotation(Annotation .OpaqueAlias (info.bounds.lo ))
386
386
setFlag(Deferred )
387
387
info = TypeBounds .empty
388
388
}
@@ -494,14 +494,15 @@ object SymDenotations {
494
494
final def isAnonymousModuleVal (implicit ctx : Context ) =
495
495
this .symbol.is(ModuleVal ) && (initial.name startsWith str.ANON_CLASS )
496
496
497
- /** Is this a companion class method or companion object method?
497
+ /** Is this a companion class or type method or companion object method?
498
498
* These methods are generated by Symbols#synthesizeCompanionMethod
499
499
* and used in SymDenotations#companionClass and
500
500
* SymDenotations#companionModule .
501
501
*/
502
502
final def isCompanionMethod (implicit ctx : Context ) =
503
503
name.toTermName == nme.COMPANION_CLASS_METHOD ||
504
- name.toTermName == nme.COMPANION_MODULE_METHOD
504
+ name.toTermName == nme.COMPANION_MODULE_METHOD ||
505
+ name.toTermName == nme.COMPANION_TYPE_METHOD
505
506
506
507
/** Is this a synthetic method that represents conversions between representations of a value class
507
508
* These methods are generated in ExtensionMethods
@@ -967,20 +968,28 @@ object SymDenotations {
967
968
}
968
969
}
969
970
970
- /** The class with the same (type-) name as this module or module class,
971
- * and which is also defined in the same scope and compilation unit.
972
- * NoSymbol if this class does not exist.
973
- */
974
- final def companionClass (implicit ctx : Context ): Symbol =
971
+ private def companionType (name : TermName )(implicit ctx : Context ): Symbol =
975
972
if (is(Package )) NoSymbol
976
973
else {
977
- val companionMethod = info.decls.denotsNamed(nme.COMPANION_CLASS_METHOD , selectPrivate).first
978
- if (companionMethod.exists)
979
- companionMethod.info.resultType.classSymbol
980
- else
981
- NoSymbol
974
+ val companionMethod = info.decls.denotsNamed(name, selectPrivate).first
975
+ if (companionMethod.exists) companionMethod.info.resultType.typeSymbol
976
+ else NoSymbol
982
977
}
983
978
979
+ /** The class with the same (type-) name as this module or module class,
980
+ * and which is also defined in the same scope and compilation unit.
981
+ * NoSymbol if this class does not exist.
982
+ */
983
+ final def companionClass (implicit ctx : Context ): Symbol =
984
+ companionType(nme.COMPANION_CLASS_METHOD ).suchThat(_.isClass).symbol
985
+
986
+ /** The opaque type with the same (type-) name as this module or module class,
987
+ * and which is also defined in the same scope and compilation unit.
988
+ * NoSymbol if this type does not exist.
989
+ */
990
+ final def companionOpaqueType (implicit ctx : Context ): Symbol =
991
+ companionType(nme.COMPANION_TYPE_METHOD ).suchThat(_.is(Opaque )).symbol
992
+
984
993
final def scalacLinkedClass (implicit ctx : Context ): Symbol =
985
994
if (this is ModuleClass ) companionNamed(effectiveName.toTypeName)
986
995
else if (this .isClass) companionNamed(effectiveName.moduleClassName).sourceModule.moduleClass
0 commit comments