aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2016-10-20 12:16:06 +0200
committerGitHub <noreply@github.com>2016-10-20 12:16:06 +0200
commitcd235600dac18ccb75ea1f1c8158ad9bd5307cdf (patch)
tree5aef344fae92a43edcf291cbeab5f81a633246ef /src
parent0d1721c8aebaf6877e9d1ea3d65d40446a869170 (diff)
parente82cb7cdb93306b5fccf6aeef0e087999f46a016 (diff)
downloaddotty-cd235600dac18ccb75ea1f1c8158ad9bd5307cdf.tar.gz
dotty-cd235600dac18ccb75ea1f1c8158ad9bd5307cdf.tar.bz2
dotty-cd235600dac18ccb75ea1f1c8158ad9bd5307cdf.zip
Merge pull request #1595 from dotty-staging/fix-#1567
Fix #1567: Widen private constructor in value class
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/transform/ExtensionMethods.scala20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/transform/ExtensionMethods.scala b/src/dotty/tools/dotc/transform/ExtensionMethods.scala
index 62a21198d..5ae4e8a54 100644
--- a/src/dotty/tools/dotc/transform/ExtensionMethods.scala
+++ b/src/dotty/tools/dotc/transform/ExtensionMethods.scala
@@ -32,6 +32,9 @@ import SymUtils._
* in [[ElimErasedValueType]].
* This is different from the implementation of value classes in Scala 2
* (see SIP-15) which uses `asInstanceOf` which does not typecheck.
+ *
+ * Finally, if the constructor of a value class is private pr protected
+ * it is widened to public.
*/
class ExtensionMethods extends MiniPhaseTransform with DenotTransformer with FullParameterization { thisTransformer =>
@@ -96,11 +99,18 @@ class ExtensionMethods extends MiniPhaseTransform with DenotTransformer with Ful
case _ =>
moduleClassSym
}
- case ref: SymDenotation
- if isMethodWithExtension(ref) && ref.hasAnnotation(defn.TailrecAnnot) =>
- val ref1 = ref.copySymDenotation()
- ref1.removeAnnotation(defn.TailrecAnnot)
- ref1
+ case ref: SymDenotation =>
+ if (isMethodWithExtension(ref) && ref.hasAnnotation(defn.TailrecAnnot)) {
+ val ref1 = ref.copySymDenotation()
+ ref1.removeAnnotation(defn.TailrecAnnot)
+ ref1
+ }
+ else if (ref.isConstructor && isDerivedValueClass(ref.owner) && ref.is(AccessFlags)) {
+ val ref1 = ref.copySymDenotation()
+ ref1.resetFlag(AccessFlags)
+ ref1
+ }
+ else ref
case _ =>
ref
}