Skip to content

Widen qualifier skolems #13748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler

given NamedTypeMethods: NamedTypeMethods with
extension (self: NamedType)
def qualifier: TypeRepr = self.prefix
def qualifier: TypeRepr = self.prefix.widenSkolem
Copy link
Member

@smarter smarter Oct 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should all reflection APIs that return possible skolems be changed to call widenSkolem? For example, x.prefix in TermRef.unapply and TypeRef.unapply could both return skolems. IMO, this is too easy to get wrong and we should instead handle skolems by exposing their parent trait SingletonType in the reflection API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if that would be a backwards compatible change.

def name: String = self.name.toString
end extension
end NamedTypeMethods
Expand Down
9 changes: 9 additions & 0 deletions tests/pos-macros/i13422/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import scala.quoted._

inline def rule(inline r: Any): Unit = ${ ruleImpl('r) }

def ruleImpl(r: Expr[Any])(using Quotes): Expr[Unit] = {
import quotes.reflect.*
r.asTerm.show
'{}
}
12 changes: 12 additions & 0 deletions tests/pos-macros/i13422/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def test = rule {
foo(bar(baz))
}

def foo[I](r: I): Nothing = ???

def bar(i: Baz): i.Out = ???

sealed trait Baz:
type Out = Nothing match { case Nothing => Nothing }

def baz: Baz = ???