File tree 2 files changed +11
-1
lines changed
compiler/src/dotty/tools/dotc/typer 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -175,10 +175,16 @@ object Checking {
175
175
if (cls.isOneOf(AbstractOrTrait ))
176
176
ctx.error(CantInstantiateAbstractClassOrTrait (cls, isTrait = cls.is(Trait )), posd.sourcePos)
177
177
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
178
183
// Create a synthetic singleton type instance, and check whether
179
184
// it conforms to the self type of the class as seen from that instance.
180
185
val stp = SkolemType (tp)
181
- val selfType = cls.asClass.givenSelfType.asSeenFrom(stp, cls)
186
+ val selfType =
187
+ cls.asClass.givenSelfType.stripOpaques.asSeenFrom(stp, cls)
182
188
if (selfType.exists && ! (stp <:< selfType))
183
189
ctx.error(DoesNotConformToSelfTypeCantBeInstantiated (tp, selfType), posd.sourcePos)
184
190
}
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