File tree 4 files changed +54
-4
lines changed
compiler/src/dotty/tools/dotc
4 files changed +54
-4
lines changed Original file line number Diff line number Diff line change @@ -1083,6 +1083,18 @@ 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 seen from inside the opaque companion object,
1087
+ * its opaque alias, otherwise the type itself.
1088
+ */
1089
+ final def followSyntheticOpaque (implicit ctx : Context ): Type = this match {
1090
+ case tp : TypeProxy if tp.typeSymbol.is(SyntheticOpaque ) =>
1091
+ tp.superType match {
1092
+ case AndType (alias, _) => alias // in this case we are inside the companion object
1093
+ case _ => this
1094
+ }
1095
+ case _ => this
1096
+ }
1097
+
1086
1098
/** The result of normalization using `tryNormalize`, or the type itself if
1087
1099
* tryNormlize yields NoType
1088
1100
*/
Original file line number Diff line number Diff line change @@ -730,13 +730,12 @@ class Typer extends Namer
730
730
case _ : WildcardType => untpd.TypeTree ()
731
731
case _ => untpd.TypeTree (tp)
732
732
}
733
- pt.stripTypeVar match {
734
- case _ if defn.isNonDepFunctionType(pt ) =>
733
+ pt.stripTypeVar.dealias.followSyntheticOpaque match {
734
+ case pt1 if defn.isNonDepFunctionType(pt1 ) =>
735
735
// if expected parameter type(s) are wildcards, approximate from below.
736
736
// if expected result type is a wildcard, approximate from above.
737
737
// this can type the greatest set of admissible closures.
738
- val funType = pt.dealias
739
- (funType.argTypesLo.init, typeTree(funType.argTypesHi.last))
738
+ (pt1.argTypesLo.init, typeTree(pt1.argTypesHi.last))
740
739
case SAMType (sam @ MethodTpe (_, formals, restpe)) =>
741
740
(formals,
742
741
if (sam.isResultDependent)
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
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
+ }
You can’t perform that action at this time.
0 commit comments