File tree Expand file tree Collapse file tree 3 files changed +31
-6
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 3 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -1083,11 +1083,15 @@ object Types {
10831083 /** Like `dealiasKeepAnnots`, but keeps only refining annotations */
10841084 final def dealiasKeepRefiningAnnots (implicit ctx : Context ): Type = dealias1(keepIfRefining)
10851085
1086- /** If this is a synthetic opaque type, its opaque alias, otherwise the type itself */
1086+ /** If this is a synthetic opaque type seen from inside the opaque companion object,
1087+ * its opaque alias, otherwise the type itself.
1088+ */
10871089 final def followSyntheticOpaque (implicit ctx : Context ): Type = this match {
10881090 case tp : TypeProxy if tp.typeSymbol.is(SyntheticOpaque ) =>
1089- val AndType (alias, _) = tp.superType
1090- alias
1091+ tp.superType match {
1092+ case AndType (alias, _) => alias // in this case we are inside the companion object
1093+ case _ => this
1094+ }
10911095 case _ => this
10921096 }
10931097
Original file line number Diff line number Diff line change 1+ object TypeAlias {
2+
3+ type Set [A ] = A => Boolean
4+
5+ object Set {
6+ def singleton [A ](a : A ): Set [A ] = _ == a
7+ }
8+ }
9+
10+ object OpaqueType {
11+
12+ opaque type Set [A ] = A => Boolean
13+
14+ object Set {
15+ def singleton [A ](a : A ): Set [A ] = _ == a
16+ def singleton0 [A ](a : A ): Set [A ] = (_ : A ) == a
17+ }
18+
19+ def singleton [A ](a : A ): Set [A ] = _ == a // error: missing parameter type
20+ }
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ object TypeAlias {
33 type Set [A ] = A => Boolean
44
55 object Set {
6- def singleton [A ](a : A ): Set [A ] = _ == a // Works
6+ def singleton [A ](a : A ): Set [A ] = _ == a
77 }
88}
99
@@ -12,7 +12,8 @@ object OpaqueType {
1212 opaque type Set [A ] = A => Boolean
1313
1414 object Set {
15- def singleton [A ](a : A ): Set [A ] = _ == a // Does not compile
16- def singleton0 [A ](a : A ): Set [A ] = (_ : A ) == a // Works
15+ def singleton [A ](a : A ): Set [A ] = _ == a
16+ def singleton0 [A ](a : A ): Set [A ] = (_ : A ) == a
1717 }
18+
1819}
You can’t perform that action at this time.
0 commit comments