Skip to content

Commit 6985b5d

Browse files
committed
Let the info of opaque types always depends on the prefix
Fixes #11277
1 parent 3b741d6 commit 6985b5d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,6 +2299,7 @@ object Types {
22992299
*/
23002300
private def infoDependsOnPrefix(symd: SymDenotation, prefix: Type)(using Context): Boolean =
23012301
symd.maybeOwner.membersNeedAsSeenFrom(prefix) && !symd.is(NonMember)
2302+
|| prefix.isInstanceOf[Types.ThisType] && symd.is(Opaque) // see pos/i11277.scala for a test where this matters
23022303

23032304
/** Is this a reference to a class or object member? */
23042305
def isMemberRef(using Context): Boolean = designator match {

tests/pos/i11277.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Foo {
2+
opaque type Num = Int
3+
4+
val z = Test.id(this)(1)
5+
}
6+
object Test {
7+
def id(f: Foo)(x: f.Num): f.Num = x
8+
}

0 commit comments

Comments
 (0)