File tree 2 files changed +23
-3
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -380,11 +380,22 @@ object SymDenotations {
380
380
case _ => unforcedDecls.openForMutations
381
381
}
382
382
383
+ /** If this is an opaque type alias, mark it as Deferred with empty bounds
384
+ * while storing the former right-hand side in an OpaqueAlias annotation.
385
+ */
383
386
final def normalizeOpaque ()(implicit ctx : Context ) = {
387
+ def abstractRHS (tp : Type ): Type = tp match {
388
+ case tp : HKTypeLambda => tp.derivedLambdaType(resType = abstractRHS(tp.resType))
389
+ case _ => defn.AnyType
390
+ }
384
391
if (is(Opaque )) {
385
- addAnnotation(Annotation .OpaqueAlias (info.bounds.lo))
386
- setFlag(Deferred )
387
- info = TypeBounds .empty
392
+ info match {
393
+ case tp @ TypeAlias (alias) =>
394
+ addAnnotation(Annotation .OpaqueAlias (alias))
395
+ info = TypeBounds (defn.NothingType , abstractRHS(alias))
396
+ setFlag(Deferred )
397
+ case _ =>
398
+ }
388
399
}
389
400
}
390
401
Original file line number Diff line number Diff line change @@ -21,3 +21,12 @@ object opaquetypes {
21
21
}
22
22
}
23
23
}
24
+ object usesites {
25
+ import opaquetypes ._
26
+ import Logarithm .LogarithmOps // todo: drop
27
+ val l = Logarithm (1.0 )
28
+ val l2 = Logarithm (2.0 )
29
+ val l3 = l + l2
30
+ val d = l3.toDouble
31
+ val l4 : Logarithm = (1.0 ).asInstanceOf [Logarithm ]
32
+ }
You can’t perform that action at this time.
0 commit comments