diff options
author | Martin Odersky <odersky@gmail.com> | 2017-03-26 12:57:28 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-04-11 09:33:10 +0200 |
commit | 47158c9ae592bab53b9618b90b2514166a8a6004 (patch) | |
tree | 993c21bcf91ddfe2b491e1f85131f2e05ce88ab5 /compiler/src/dotty/tools/dotc/core/NameOps.scala | |
parent | 2ab37596efc9cd19081ee009fc97d46cf6c35896 (diff) | |
download | dotty-47158c9ae592bab53b9618b90b2514166a8a6004.tar.gz dotty-47158c9ae592bab53b9618b90b2514166a8a6004.tar.bz2 dotty-47158c9ae592bab53b9618b90b2514166a8a6004.zip |
Properly integrate TraitSetter names
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/NameOps.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/NameOps.scala | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/NameOps.scala b/compiler/src/dotty/tools/dotc/core/NameOps.scala index 9d5d3bd6a..6d58a82bc 100644 --- a/compiler/src/dotty/tools/dotc/core/NameOps.scala +++ b/compiler/src/dotty/tools/dotc/core/NameOps.scala @@ -82,7 +82,9 @@ object NameOps { def isLoopHeaderLabel = (name startsWith WHILE_PREFIX) || (name startsWith DO_WHILE_PREFIX) def isProtectedAccessorName = name startsWith PROTECTED_PREFIX def isReplWrapperName = name.toSimpleName containsSlice INTERPRETER_IMPORT_WRAPPER - def isTraitSetterName = name.toSimpleName containsSlice TRAIT_SETTER_SEPARATOR + def isTraitSetterName = + if (Config.semanticNames) name.is(NameInfo.TraitSetterKind) + else name containsSlice TRAIT_SETTER_SEPARATOR def isSetterName = name endsWith SETTER_SUFFIX def isSingletonName = name endsWith SINGLETON_SUFFIX def isModuleClassName = @@ -437,10 +439,16 @@ object NameOps { def fieldName: TermName = if (name.isSetterName) { if (name.isTraitSetterName) { - // has form <$-separated-trait-name>$_setter_$ `name`_$eq - val start = name.lastPart.indexOfSlice(TRAIT_SETTER_SEPARATOR) + TRAIT_SETTER_SEPARATOR.length - val end = name.lastPart.indexOfSlice(SETTER_SUFFIX) - name.mapLast(n => (n.slice(start, end) ++ LOCAL_SUFFIX).asSimpleName) + if (Config.semanticNames) { + val DerivedTermName(_, NameInfo.TraitSetter(original)) = name + original ++ LOCAL_SUFFIX + } + else { + // has form <$-separated-trait-name>$_setter_$ `name`_$eq + val start = name.indexOfSlice(TRAIT_SETTER_SEPARATOR) + TRAIT_SETTER_SEPARATOR.length + val end = name.indexOfSlice(SETTER_SUFFIX) + (name.slice(start, end) ++ LOCAL_SUFFIX).asTermName + } } else getterName.fieldName } else name.mapLast(n => (n ++ LOCAL_SUFFIX).asSimpleName) |