diff options
-rw-r--r-- | src/reflect/scala/reflect/api/Types.scala | 2 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 2 | ||||
-rw-r--r-- | test/files/run/reflection-companiontype.scala | 18 |
3 files changed, 11 insertions, 11 deletions
diff --git a/src/reflect/scala/reflect/api/Types.scala b/src/reflect/scala/reflect/api/Types.scala index 90f12294c6..e026375ce5 100644 --- a/src/reflect/scala/reflect/api/Types.scala +++ b/src/reflect/scala/reflect/api/Types.scala @@ -132,7 +132,7 @@ trait Types { /** Type signature of the companion of the underlying class symbol. * NoType if the underlying symbol is not a class symbol, or if it doesn't have a companion. */ - def companionType: Type + def companion: Type /** Is this type a type constructor that is missing its type arguments? */ diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 3bcc07caca..5da6ce026e 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -244,7 +244,7 @@ trait Types this.isInstanceOf[TypeRef] && typeSymbol.isAbstractType && !typeSymbol.isExistential } - def companionType = { + def companion = { val sym = typeSymbolDirect if (sym.isModule && !sym.isPackage) sym.companionSymbol.tpe else if (sym.isModuleClass && !sym.isPackageClass) sym.sourceModule.companionSymbol.tpe diff --git a/test/files/run/reflection-companiontype.scala b/test/files/run/reflection-companiontype.scala index 7f2a37aaa9..0f63457670 100644 --- a/test/files/run/reflection-companiontype.scala +++ b/test/files/run/reflection-companiontype.scala @@ -8,15 +8,15 @@ object Test extends App { type T = C println("TypeRefs") - println(showRaw(typeOf[C].companionType, printKinds = true)) - println(showRaw(typeOf[C].companionType.companionType, printKinds = true)) - println(showRaw(typeOf[C.type].companionType, printKinds = true)) + println(showRaw(typeOf[C].companion, printKinds = true)) + println(showRaw(typeOf[C].companion.companion, printKinds = true)) + println(showRaw(typeOf[C.type].companion, printKinds = true)) println("ClassInfoTypes") - println(showRaw(typeOf[C].typeSymbol.info.companionType, printKinds = true)) - println(showRaw(typeOf[C].typeSymbol.info.companionType.typeSymbol.info.companionType, printKinds = true)) - println(showRaw(typeOf[C.type].typeSymbol.info.companionType, printKinds = true)) + println(showRaw(typeOf[C].typeSymbol.info.companion, printKinds = true)) + println(showRaw(typeOf[C].typeSymbol.info.companion.typeSymbol.info.companion, printKinds = true)) + println(showRaw(typeOf[C.type].typeSymbol.info.companion, printKinds = true)) println("Unrelated") - println(showRaw(typeOf[T].companionType, printKinds = true)) - println(showRaw(cm.staticPackage("scala").moduleClass.asType.toType.companionType, printKinds = true)) - println(showRaw(cm.staticPackage("scala").info.companionType, printKinds = true)) + println(showRaw(typeOf[T].companion, printKinds = true)) + println(showRaw(cm.staticPackage("scala").moduleClass.asType.toType.companion, printKinds = true)) + println(showRaw(cm.staticPackage("scala").info.companion, printKinds = true)) }
\ No newline at end of file |