Skip to content

Conversation

@som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Aug 5, 2025

Fixes #23666

Improve use of existing API. The fix is instead of using param's symbol.info, use symbol.typeRef.dealias and follow upper bounds, with a special case in the "subsumes" check for type param; and also a guard to not dealias an opaque type by using its bounds.

@som-snytt som-snytt marked this pull request as ready for review August 5, 2025 20:47
@som-snytt
Copy link
Contributor Author

Ready for review in the sense of open to suggestions.

@som-snytt
Copy link
Contributor Author

I appreciate the Odersky PR that says "we need a better solution". This is such a PR, if only it had a PR label.

val target =
val target0 = explicitInfo.firstParamTypes.head // required for extension method, the putative receiver
target0.dealiasKeepOpaques.typeSymbol.info
target0.dealiasKeepOpaques.typeSymbol.info match
Copy link
Contributor

Choose a reason for hiding this comment

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

This is kind of weird since dealias does skip aliasing bounds. It would be good to get an explanation what exactly goes wrong here. What's the type of target0.dealiasKeepOpaques in the failing test? What is its info? Is there an opaque type involved?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The correct working idiom is

explicitInfo.firstParamTypes.head.typeSymbol.typeRef.dealiasKeepOpaques

but requires reworking https://github.com/scala/scala3/pull/22502/files
or dealias should handle TypeAlias directly.

@odersky odersky assigned som-snytt and unassigned odersky Aug 6, 2025
@som-snytt som-snytt marked this pull request as draft August 6, 2025 15:05
@som-snytt som-snytt force-pushed the issue/23666-extension-crash branch from 36dba58 to 8edcb7c Compare November 23, 2025 06:34
In refchecks for extension methods, obtain a TypeRef
of the receiver parameter type, so that it is correctly
dealiased. The prior idiom produced a TypeAlias.
@som-snytt som-snytt force-pushed the issue/23666-extension-crash branch from 8edcb7c to b289913 Compare November 23, 2025 12:59
@som-snytt
Copy link
Contributor Author

Flaky test in CB probes doesnt-exist.com?

[123-1] X requests.RequestTests.failures 417ms 
[123-1]   requests.RequestFailedException: Request to https://doesnt-exist.com/ failed with status code 403
[123-1]   <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=Edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="robots" content="noindex,nofollow"><meta http-equiv="refresh" content="30"><link rel="preconnect" href="https://fonts.googleapis.com/"><link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin><link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;600&display=swap" rel="stylesheet"><title>Checking your browser before accessing. Just a moment...</title>

@som-snytt som-snytt marked this pull request as ready for review November 23, 2025 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when type alias has extension method with the same name as the underlying type

2 participants