Skip to content

Commit 2545c8c

Browse files
committed
Adjust member.info (removing This) instead of changing self
1 parent 17217b5 commit 2545c8c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

+9-6
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
16941694
end SimpleSelectorTypeTest
16951695

16961696
object SimpleSelector extends SimpleSelectorModule:
1697-
def apply(name: String): SimpleSelector =
1697+
def apply(name: String): SimpleSelector =
16981698
withDefaultPos(untpd.ImportSelector(untpd.Ident(name.toTermName)))
16991699
def unapply(x: SimpleSelector): Some[String] = Some(x.name.toString)
17001700
end SimpleSelector
@@ -1837,11 +1837,14 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
18371837
def termSymbol: Symbol = self.termSymbol
18381838
def isSingleton: Boolean = self.isSingleton
18391839
def memberType(member: Symbol): TypeRepr =
1840-
// we use thisType to avoid resolving otherwise unstable prefixes into Nothing
1841-
val classSymbol = self.classSymbol
1842-
member.info
1843-
.asSeenFrom(classSymbol.thisType, member.owner)
1844-
.substThis(classSymbol.asClass, self) // and we remove the previously added This(_) for compatibility
1840+
// we replace thisTypes here to avoid resolving otherwise unstable prefixes into Nothing
1841+
val memberInfo =
1842+
if self.typeSymbol.isClassDef then
1843+
member.info.substThis(self.classSymbol.asClass, self)
1844+
else
1845+
member.info
1846+
memberInfo
1847+
.asSeenFrom(self, member.owner)
18451848

18461849
def baseClasses: List[Symbol] = self.baseClasses
18471850
def baseType(cls: Symbol): TypeRepr = self.baseType(cls)

0 commit comments

Comments
 (0)