File tree 3 files changed +31
-6
lines changed
compiler/src/dotty/tools/dotc/core
3 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -1083,11 +1083,15 @@ object Types {
1083
1083
/** Like `dealiasKeepAnnots`, but keeps only refining annotations */
1084
1084
final def dealiasKeepRefiningAnnots (implicit ctx : Context ): Type = dealias1(keepIfRefining)
1085
1085
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
+ */
1087
1089
final def followSyntheticOpaque (implicit ctx : Context ): Type = this match {
1088
1090
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
+ }
1091
1095
case _ => this
1092
1096
}
1093
1097
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 {
3
3
type Set [A ] = A => Boolean
4
4
5
5
object Set {
6
- def singleton [A ](a : A ): Set [A ] = _ == a // Works
6
+ def singleton [A ](a : A ): Set [A ] = _ == a
7
7
}
8
8
}
9
9
@@ -12,7 +12,8 @@ object OpaqueType {
12
12
opaque type Set [A ] = A => Boolean
13
13
14
14
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
17
17
}
18
+
18
19
}
You can’t perform that action at this time.
0 commit comments