From 8a849a4b5b5c682263ca5a2cd5a1693ee7cbbb02 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 20 Feb 2016 16:31:05 +0100 Subject: [PATCH 1/2] Default getters accessibility fix Default getters should have same accessibility as the method they belong to. Previously, it was the accessibility of the parameter, which makes no sense. Fixes #1116. --- src/dotty/tools/dotc/ast/Desugar.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index 31ebc4a7d40f..89b5a7699603 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -186,7 +186,7 @@ object desugar { vparamss = takeUpTo(normalizedVparamss, n), tpt = TypeTree(), rhs = vparam.rhs - ).withMods(vparam.mods & AccessFlags) + ).withMods(mods & AccessFlags) val rest = defaultGetters(vparams :: vparamss1, n + 1) if (vparam.rhs.isEmpty) rest else defaultGetter :: rest case Nil :: vparamss1 => From 71fd9dc32eb3777c55ef276bed9fd43d36bdc053 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 20 Feb 2016 16:45:57 +0100 Subject: [PATCH 2/2] Don't copy annotations from method to default getter. --- src/dotty/tools/dotc/ast/Desugar.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index 89b5a7699603..e9c641282857 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -186,7 +186,7 @@ object desugar { vparamss = takeUpTo(normalizedVparamss, n), tpt = TypeTree(), rhs = vparam.rhs - ).withMods(mods & AccessFlags) + ).withMods(Modifiers(mods.flags & AccessFlags, mods.privateWithin)) val rest = defaultGetters(vparams :: vparamss1, n + 1) if (vparam.rhs.isEmpty) rest else defaultGetter :: rest case Nil :: vparamss1 =>