File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -175,10 +175,16 @@ object Checking {
175175 if (cls.isOneOf(AbstractOrTrait ))
176176 ctx.error(CantInstantiateAbstractClassOrTrait (cls, isTrait = cls.is(Trait )), posd.sourcePos)
177177 if (! cls.is(Module )) {
178+ def (tp : Type ).stripOpaques: Type = tp match
179+ case RefinedType (parent, name, _) if cls.info.decl(name).symbol.isOpaqueAlias =>
180+ parent.stripOpaques
181+ case _ =>
182+ tp
178183 // Create a synthetic singleton type instance, and check whether
179184 // it conforms to the self type of the class as seen from that instance.
180185 val stp = SkolemType (tp)
181- val selfType = cls.asClass.givenSelfType.asSeenFrom(stp, cls)
186+ val selfType =
187+ cls.asClass.givenSelfType.stripOpaques.asSeenFrom(stp, cls)
182188 if (selfType.exists && ! (stp <:< selfType))
183189 ctx.error(DoesNotConformToSelfTypeCantBeInstantiated (tp, selfType), posd.sourcePos)
184190 }
Original file line number Diff line number Diff line change 1+ class Abc :
2+ opaque type Log = Double
3+
4+ val v : Abc = new Abc
You can’t perform that action at this time.
0 commit comments