Skip to content

TraitConstructors: Use a valid method name for the initializer (fix #577) #589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ object SymDenotations {
encl = encl.owner
sep += "~"
}
if (owner.is(ModuleClass) && sep == "$") sep = "" // duplicate scalac's behavior: don't write a double '$$' for module class members.
if (owner.is(ModuleClass, butNot = Package) && sep == "$") sep = "" // duplicate scalac's behavior: don't write a double '$$' for module class members.
val fn = encl.fullNameSeparated(separator) ++ sep ++ name
if (isType) fn.toTypeName else fn.toTermName
}
Expand Down
3 changes: 2 additions & 1 deletion src/dotty/tools/dotc/transform/TraitConstructors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class TraitConstructors extends MiniPhaseTransform with SymTransformer {

def transformSym(sym: SymDenotation)(implicit ctx: Context): SymDenotation = {
if (sym.isPrimaryConstructor && (sym.owner is Flags.Trait))
sym.copySymDenotation(name = nme.INITIALIZER_PREFIX ++ sym.owner.fullName)
// TODO: Someone needs to carefully check if name clashes are possible with this mangling scheme
sym.copySymDenotation(name = nme.INITIALIZER_PREFIX ++ sym.owner.fullNameSeparated("$"))
else sym
}

Expand Down