diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index 2d71bd350b3b..33470c9f41bc 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -432,8 +432,8 @@ object SymDenotations { TypeBounds.empty info match - case TypeAlias(alias) if isOpaqueAlias && owner.isClass => - setAlias(alias) + case info: AliasingBounds if isOpaqueAlias && owner.isClass => + setAlias(info.alias) HKTypeLambda.boundsFromParams(tparams, bounds(rhs)) case _ => info diff --git a/compiler/src/dotty/tools/dotc/core/TypeOps.scala b/compiler/src/dotty/tools/dotc/core/TypeOps.scala index eb353744ae82..2e13641d0f9b 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeOps.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeOps.scala @@ -420,7 +420,7 @@ object TypeOps: sym.is(Package) || sym.isStatic && isStaticPrefix(pre.prefix) case _ => true - def apply(tp: Type): Type = tp match { + def apply(tp: Type): Type = tp match case tp: TermRef if toAvoid(tp.symbol) || partsToAvoid(Nil, tp.info).nonEmpty => tp.info.widenExpr.dealias match { @@ -459,7 +459,7 @@ object TypeOps: mapOver(tl) case _ => mapOver(tp) - } + end apply /** Three deviations from standard derivedSelect: * 1. We first try a widening conversion to the type's info with diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 8a0b0f12c167..c0395ace5313 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -423,6 +423,10 @@ object Types { def isMatch(using Context): Boolean = stripped match { case _: MatchType => true case tp: HKTypeLambda => tp.resType.isMatch + case tp: AppliedType => + tp.tycon match + case tycon: TypeRef => tycon.info.isInstanceOf[MatchAlias] + case _ => false case _ => false } diff --git a/compiler/test/dotc/run-test-pickling.blacklist b/compiler/test/dotc/run-test-pickling.blacklist index d36314e896d8..5bcca090e8c6 100644 --- a/compiler/test/dotc/run-test-pickling.blacklist +++ b/compiler/test/dotc/run-test-pickling.blacklist @@ -33,3 +33,4 @@ typeclass-derivation2d.scala typeclass-derivation3.scala varargs-abstract zero-arity-case-class.scala +i12194.scala diff --git a/tests/pos/i12178.scala b/tests/pos/i12178.scala new file mode 100644 index 000000000000..4247ad92301b --- /dev/null +++ b/tests/pos/i12178.scala @@ -0,0 +1,24 @@ +opaque type LabelTagged[TLabel <: Singleton & String, TValue] = TValue + +object LabelTagged: + def apply[TLabel <: Singleton & String, TValue] + ( + label: TLabel, + value: TValue, + ) + : LabelTagged[TLabel, TValue] = value + +extension[TLabel <: Singleton & String, TValue] (labelTagged: LabelTagged[TLabel, TValue]) + def value + : TValue = labelTagged + + def label + (using label: ValueOf[TLabel]) + : TLabel + = label.value + +@main def hello(): Unit = { + val foo: LabelTagged["foo", Int] = LabelTagged("foo", 10) + println(label(foo)) // OK + //println(foo.label) // not OK +} diff --git a/tests/pos/i12194-opaque.scala b/tests/pos/i12194-opaque.scala new file mode 100644 index 000000000000..b800d27bb140 --- /dev/null +++ b/tests/pos/i12194-opaque.scala @@ -0,0 +1,3 @@ +opaque type ProductK[F[_], T <: Tuple] = Tuple.Map[T, F] +object ProductK: + def of[F[_], T <: Tuple](t: Tuple.Map[T, F]): ProductK[F, T] = t diff --git a/tests/run/i12194.check b/tests/run/i12194.check new file mode 100644 index 000000000000..9e90577cbd4f --- /dev/null +++ b/tests/run/i12194.check @@ -0,0 +1 @@ +List(foo, bar) diff --git a/tests/run/i12194.scala b/tests/run/i12194.scala new file mode 100644 index 000000000000..29916c461549 --- /dev/null +++ b/tests/run/i12194.scala @@ -0,0 +1,16 @@ +import scala.annotation.implicitNotFound +import scala.compiletime.package$package.summonAll +import scala.util.Try +import scala.util.Success +import scala.util.Failure +import scala.util.NotGiven +import scala.deriving.* + +def f(): Unit = + var t = (??? : Tuple1[ValueOf["foo"]]); t.toList.map(identity) + (??? : Tuple1[ValueOf["foo"]]).toList.map(identity) + +@main def Test(): Unit = + println(summonAll[Tuple.Map[("foo", "bar"), ValueOf]].toList.map{ + case str: ValueOf[_] ⇒ str.value + }) \ No newline at end of file