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