Skip to content

Conversation

olhotak
Copy link
Contributor

@olhotak olhotak commented Jun 14, 2025

propOrElse exploits unsoundness of flexible types to take a nullable alt and return it as a non-null String. This is due to a flexible type being inferred as the type argument of Option.apply and of getOrElse(). It's possible that a null alt could be passed to propOrElse and it would return it, violating its return type. This refactoring cleans up propOrElse and related methods; it specifies a type argument explicitly to ensure that a flexible type is not inferred.

`propOrElse` exploits unsoundness of flexible types to take a nullable `alt` and return it as a non-null `String`. This is due to a flexible type being inferred as the type argument of `Option.apply` and of `getOrElse()`. It's possible that a `null` `alt` could be passed to `propOrElse` and it would return it, violating its return type. This refactoring cleans up `propOrElse` and related methods; it specifies a type argument explicitly to ensure that a flexible type is not inferred.
@olhotak olhotak requested a review from noti0na1 June 14, 2025 15:09
@olhotak
Copy link
Contributor Author

olhotak commented Jun 14, 2025

cc @HarrisL2 @SuperCl4sh

@olhotak olhotak merged commit 372f889 into scala:main Jun 14, 2025
29 checks passed
@olhotak olhotak deleted the tweak-flexible-types-in-properties branch June 14, 2025 17:30
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.

2 participants