From 6985b5dd9eebdc150ac1063ba7c4de2ca6991efb Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 3 Feb 2021 14:23:14 +0100 Subject: [PATCH] Let the info of opaque types always depends on the prefix Fixes #11277 --- compiler/src/dotty/tools/dotc/core/Types.scala | 1 + tests/pos/i11277.scala | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 tests/pos/i11277.scala diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 59f8c37cbf55..e5b826e4f2b1 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -2299,6 +2299,7 @@ object Types { */ private def infoDependsOnPrefix(symd: SymDenotation, prefix: Type)(using Context): Boolean = symd.maybeOwner.membersNeedAsSeenFrom(prefix) && !symd.is(NonMember) + || prefix.isInstanceOf[Types.ThisType] && symd.is(Opaque) // see pos/i11277.scala for a test where this matters /** Is this a reference to a class or object member? */ def isMemberRef(using Context): Boolean = designator match { diff --git a/tests/pos/i11277.scala b/tests/pos/i11277.scala new file mode 100644 index 000000000000..b1dd6a2a119f --- /dev/null +++ b/tests/pos/i11277.scala @@ -0,0 +1,8 @@ +class Foo { + opaque type Num = Int + + val z = Test.id(this)(1) +} +object Test { + def id(f: Foo)(x: f.Num): f.Num = x +} \ No newline at end of file